Project

Basic programming

1) A= [1,2,3,4,5] represents an array of 5 numbers in horizontal direction.

Output is A =1 2 3 4 5

2) B=[1;2;3;4;5] represents an array of 5 numbers in vertical direction.

Output is B =

1
2
3
4
5

3) C=A*B\' represents no output. reason as follows:

Incorrect dimensions for matrix multiplication. As the number of columns in the first matrix does not matches the number of rows in the second matrix.

4)C = B*A represents matrix multiplication of both the matrix A and B as the number of columns in the first matrix matches the number of rows in the second matrix.

Expected output 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) represents the total numbers in an array A.

Output is A(1:end)= 1 2 3 4 5

6)A(1:2) represents the first two numbers in an array A.

Output is A(1:2)= 1 2

7) B(1:2,3) represents no output.

Reason: Here the given array B is 1 D. so in order to execute the command it has to be B(1:2,1).

To execute B(1:2,3) the array B has to be 3D.

8) B(length(B)-2) represents the number of elements in an array B - 2.

thus total numbers in B array are 5

5-2= 3

Output of B(length(B)-2) is 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.