How can I remove an entire row of zeros in a matrix?

1 vue (au cours des 30 derniers jours)
Dario
Dario le 8 Mar 2018
If I have a matrix like this one:
45 23 54
0 0 0
9 3 32
How can I remove the second row and obtain this matrix?
45 23 54
9 3 32

Réponse acceptée

David Fletcher
David Fletcher le 8 Mar 2018
Modifié(e) : David Fletcher le 8 Mar 2018
a=[45 23 54;0 0 0;9 3 32];
zero=a==0;
ind=all(zero,2);
a(ind,:)=[]
Presumably the entire row has to have zero in every column for it to be removed

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by