I need the command help to do the following. Situation.
A = [2 3 4;7 8 1;3 2 7;1 9 3];
I want to square this matrix and then want to save the 2nd and 3rd row of the result matrix(4x3) matrix to another matrix of 2x3 dimension. I can do like this
B = A.^2; C = B(2:3,:); now C contains my required result.
But I want to avoid the intermediate step of first saving it in matrix B above. I want the C matrix directly from A. I need a single line command for above two statements.
I tried like following C = (A.^2)(2:3,:); But it is showing syntax error.
Please help me in this.
No products are associated with this question.
EDIT Needed to strain my eyes harder to figure out that the matrix in question had 4 rows
C = [0 1 0 0; 0 0 1 0] * A.^2;