how to extract special elements from a matrix
Ältere Kommentare anzeigen
Hi, I have a matrix, let say M1 = [1,0,0,8;0,0,15,0;0,0,0,0;7,0,0,0].
How can I extract only non-zero elements to another matrix M2.
Thank you.
Antworten (2)
Andrei Bobrov
am 13 Okt. 2012
M2 = nonzeros(M1);
Walter Roberson
am 13 Okt. 2012
M2 = M1(M1 ~= 0);
Kategorien
Mehr zu Aerospace Blockset finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!