I have a matrix obtained
A=[ 1 2 3 4;5 6 7 8;9 10 11 12; 13 14 15 16];
So I just would like to obtain another matrix but with some indexs (or elements ) and the rest is zeros
So I need the output matrix to be
O=[ 1 2 0 0 ;2 1 0 0 ;0 0 6 8;0 0 8 16]
So can anyone advise me with the best way ?
Thanks,
2 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/501858-create-a-matrix-from-matrix-with-zeros-elements#comment_789723
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/501858-create-a-matrix-from-matrix-with-zeros-elements#comment_789723
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/501858-create-a-matrix-from-matrix-with-zeros-elements#comment_790367
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/501858-create-a-matrix-from-matrix-with-zeros-elements#comment_790367
Sign in to comment.