Project

Basic coding

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

This creates a 1x5 matrix. The symbol \',\' after each number denotes a new column.

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

Output: This command creates a 5x1 matrix (5 rows and 1 column)

The symbol \';\' is used between numbers to denote new rows.

3. C = A*B\'

Output: Error.

The output is error because the operator \' is not defined.

4. C = B*A

Output: It gives a 5x5 matrix.

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

The * symbol is used to multiply two matrices.

5. A(1:end)

Output: It displays all values in the matrix A

1 2 3 4 5

The symbol \':\' means \'upto\' (i.e. 1:9 means all values from 1 \'upto\' 9)

6. A(1:2)

Output: It displays first two values in the Matrix A

1 2

7. B(1:2,3)

Output: Error.

The output is error because B is a 5x1 matrix and so it does not have a third column.

The output is possible if the command is B(1:2,1)

8. B(length(B)-2)

Output: 3

The \'length\' command is used to know the number of rows or columns. It displays whichever is greater (either row or column in a matrix)

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.