remove rows with all zeros

 Respuesta aceptada

Walter Roberson
Walter Roberson el 6 de Jun. de 2012

16 votos

b = a(any(a,2),:);

5 comentarios

Rahul
Rahul el 6 de Jun. de 2012
thanks Walter
Brodie Norfolk
Brodie Norfolk el 13 de Abr. de 2017
walter cheers mate
Walter Roberson
Walter Roberson el 10 de Oct. de 2017
Note: the above code treats nan values the same as zero values, so for example the row [0 nan nan] would also be removed. If that is not acceptable, then
b = a(any(a ~= 0,2),:);
Mohamed Nedal
Mohamed Nedal el 20 de Dic. de 2019
Hi Walter,
Would you please explain this line?
b = a(any(a,2),:);
Shishir Bapat
Shishir Bapat el 11 de Mzo. de 2021
Thank you

Iniciar sesión para comentar.

Más respuestas (1)

Geoff
Geoff el 6 de Jun. de 2012

0 votos

Search facility on Answers shows this question is asked a lot... Here's one of the more recent.

Categorías

Productos

Etiquetas

Preguntada:

el 6 de Jun. de 2012

Comentada:

el 11 de Mzo. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by