delete rows which contain at least 1 zero

44 visualizzazioni (ultimi 30 giorni)
Mate 2u
Mate 2u il 7 Giu 2012
Spostato: Voss il 24 Mar 2024
Hi there I have a large matrix A. I want to delete every row which contains at least 1 zero in the row.

Risposta accettata

Andrei Bobrov
Andrei Bobrov il 7 Giu 2012
out = A(all(A,2),:);
or
out=A;
out(any(A==0,2),:) = [];
  2 Commenti
Anthony Mukanya
Anthony Mukanya il 17 Ago 2015
Spostato: Voss il 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
Alyaa Ghazi
Alyaa Ghazi il 24 Mar 2024
great,it's very useful

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by