Project

Coding Basics

1. A=[1,2,3,4,5]

The above command creates a matrix \'A\' with 1 row and 5 columns containing values 1,2,3,4,5 in each column respectively
So the output will be


A = 1 2 3 4 5


2. B=[1;2;3;4;5]

The above command creates a matrix \'B\' with 1 column and 5 rows containing values 1 2 3 4 5 in each row respectively.
So the output will be

B =

1

2

3

4

5

3. C = A*B\'

The above command multiplies matrix \'A\' with transpose of matrix \'B\'.The output from this command is not possible as we have matrix \'A\' of size 1x5 and also trasnpose of \'B\' of size 1x5. To carry out matrix multiplication the number of columns in the \'A\' should equal the number of rows in the \'B\'.

4. C = B*A

The above command creates a matrix \'C\' by carrying out matrix multiplication of \'B\' and \'A\' and 5x5 matrix is created.

So the output will be

C =

1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25

5. A(1:end)

The above command gives the values in matrix \'A\' starting from 1st to end value. So this command will give output such as


ans =

1 2 3 4 5

6. A(1:2)

The above command gives the values in matrix A starting from 1st value to second value.

So the output will be

ans =

1 2

7. B(1:2,3)

The above command will give values starting from 1st value to second value in 3rd row of matrix \'B\' .

No output is possible as there is no 3rd row in matrix \'B\'

8. B(length(B)-2)

The above command will subtract 2 from the length of \'B\'.

So the output will be

ans =

3

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.