consider the following arrays defined in matlabs workspace: w=[1 0 0 0; 2 3 0 0 ;4 5 6 0 ;7 8 9 1] retreve the following sub-matrices from w single line of matlab code: [2 0; 7 9] [0 0 0 0 0 0] [1 1]
consider the following arrays defined in matlabs workspace:
w=[1 0 0 0; 2 3 0 0 ;4 5 6 0 ;7 8 9 1]
retreve the following sub-matrices from w single line of matlab code:
[2 0; 7 9]
[0 0 0 0 0 0]
[1 1]
Given Matrix W is
Now, first sub-matrix that is required is, say matrix X
Here the matrix X contains elements of matrix W as
2 = second row and first column of matrix W
0 = second row and third column of matrix W
7 = fourth row and first column of matrix W
9 = fourth row and third column of matrix W
So, in resultant matrix X, alternate elements of the second row and fourth row are needed along with alternate elements of the first and third columns.
To implement this using MATLAB, the required code will be
Ans=
This gives the required sub-matrix X.
The second sub-matrix that is required from matrix W is, say matrix Y
These are the elements of matrix W formed by removing lower triangular matrix and forming array from the rest of elements such that matrix Y so formed will be of (1 X 6) dimension.
The elements of matrix W along with their linear indices are shown below. Linear indices are mentioned on the uppermost left corner.
Step by step
Solved in 5 steps with 11 images