how to count the number of non zero elements present in each row and column.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
jaah navi
am 6 Jun. 2019
Kommentiert: Image Analyst
am 6 Jun. 2019
If a=[3.6910 4.5873 0 0 0;
0 7.2707 0 0 3.7516;
0 0 0 0 0]
I want to count the number of non zero elements present in every row and column
I tried with the following command numel(a) where it gives the entire number of elements present in a.
Could anyone please help me on this.
2 Kommentare
Akzeptierte Antwort
Image Analyst
am 6 Jun. 2019
Try this
zerosInColumn = sum(a ~= 0, 1);
zerosInRow = sum(a ~= 0, 2);
2 Kommentare
Image Analyst
am 6 Jun. 2019
I answered a very very similar question that you asked here in this link
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays 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!