filtering values in a matrix

2 visualizaciones (últimos 30 días)
suresh G
suresh G el 11 de Mzo. de 2013
for example I have a matrix
A=1 2
3 0
0 0
4 5
0 6
I need to filter out only those rows having no zeros(in this case [4 5]). thank you for your help.........
  2 comentarios
Image Analyst
Image Analyst el 11 de Mzo. de 2013
Why does row 1, with [1,2] in it, get to remain?
suresh G
suresh G el 11 de Mzo. de 2013
oh sorry.......that was a mistake by me.... also i need to filter out those rows with atleast one zero, so that my result should be A=[1 2; 4 5]

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 11 de Mzo. de 2013
A( all(A,2), : ) = [];
If "filter out" means to remove.
  3 comentarios
Walter Roberson
Walter Roberson el 11 de Mzo. de 2013
A( ~all(A,2), : ) = [];
suresh G
suresh G el 11 de Mzo. de 2013
thnx a lot.....

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by