remove the zeros in the Matrix
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali ALATAWI
am 19 Nov. 2021
Bearbeitet: Adam Danz
am 19 Nov. 2021
How can I remove the zeros from matrix A ??

0 Kommentare
Akzeptierte Antwort
Adam Danz
am 19 Nov. 2021
Bearbeitet: Adam Danz
am 19 Nov. 2021
Here's how to remove rows or columns that contain only 0s
data = [0 0 0 0; 0 4 5 2; 0 2 5 4; 0 2 4 1]
rowsAll0 = all(data==0,1); % columns of 0s
data(:, rowsAll0) = [];
colsAll0 = all(data==0,2); % rows of 0s
data(colsAll0, :) = []
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!