Prev: GA
Next: Simulink
From: Ozge Taskan on
Hi,

I have a matrix (n,4) and some rows are all zero and I try to find in which row all numbers are zero like

[1 8 9 0; 0 0 0 0; 8 9 7 6; 7 0 8 0; 0 0 0 0 ]

I just want to get the answer as ans=[2 5]. I tried to use find function but it cannot give which row. Can it be possible?

Thank you very much in advance.

Ozge
From: Sadik on
Assuming your matrix is M, this should work:

zeroRows = find(sum(abs(M),2))==0);
From: Frank Chang on
On Jun 11, 11:27 am, "Sadik " <sadik.h...(a)gmail.com> wrote:
> Assuming your matrix is M, this should work:
>
> zeroRows = find(sum(abs(M),2))==0);

my thoughts are exactly along this line. you beat me on this. :)
From: Matt Fig on
find(~any(M,2))
 | 
Pages: 1
Prev: GA
Next: Simulink