delete rows which contain at least 1 zero
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi there I have a large matrix A. I want to delete every row which contains at least 1 zero in the row.
0 commentaires
Réponse acceptée
Andrei Bobrov
le 7 Juin 2012
out = A(all(A,2),:);
or
out=A;
out(any(A==0,2),:) = [];
2 commentaires
Anthony Mukanya
le 17 Août 2015
Déplacé(e) : Voss
le 24 Mar 2024
Thanks Andrei,
I tried what you suggested and it worked.
Now I would like to know what I should do keep the last row even if it contains a zero. The reason for this is because the entry on the nth row and jth must be zero.
Thanks
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!