What will be the value of s after this command: A = [1:4; -2:2:5; 3 1 0 -1]; s = A(end-1,end-1);
Answers
Answered by
2
Given :
A = [1 : 4 ; -2 : 2 : 5 ; 3 1 0 -1];
s = A(end - 1 , end - 1);
Solution :
A = [1 : 4 ; -2 : 2 : 5; 3 1 0 -1];
This will give us matrix
1 : 4 = 1 2 3 4
-2 : 2 : 5 = -2 0 2 4
3 1 0 -1 = 3 1 0 -1
So, matrix will be :
1 2 3 4
-2 0 2 4
3 1 0 -1
Number of rows (R)= 3
Numbers of columns (C)= 4
s = A(end-1 , end-1);
A(end - 1 , end -1) = A(R - 1 , C - 1) = A(3 - 1 , 4 - 1) = A(2 , 3)
We got the coordinates : (2 , 3)
So, s will store the element which is at the position (2 , 3)
So, s = 2
Finally the value of s is 2.
Similar questions