Project

Basic Commands In MATLAB

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

this statement gives the output 1 2 3 4 5 in a row.

output= 1 2 3 4 5

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

this statement gives the output 1 2 3 4 5 in a column.

output= 1

2

3

4

5

3. C=A*B\'

this statement doesn\'t give any output as the matrices multiplied is of the same oreder i.e. 1X5 because B\' reverses the B matrix from 5X1 to 1X5.

4. C=B*A

this statement multiplies the matrix B to A.

output= 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)

this statement generates the output 1 to 5 as the end limit was set earlier 5.

output= 1 2 3 4 5

6. A(1:2)

this will create an array starting from 1 and ending at 2.

output= 1 2

7. B(1:2,3)

this statement doesn\'t give any output as the value 3 is out of bound B(I,J)

8. B(length(B)-2)

this statement will reduce the length of B or we can say that it will cutshort the values of B.

output= 3 (as the total value in B is 5 i.e. 1 2 3 4 5)

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.