Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
finding the row number

Subject: finding the row number

From: Ozge Taskan

Date: 11 Jun, 2010 14:52:05

Message: 1 of 4

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

Subject: finding the row number

From: Sadik

Date: 11 Jun, 2010 15:27:04

Message: 2 of 4

Assuming your matrix is M, this should work:

zeroRows = find(sum(abs(M),2))==0);

Subject: finding the row number

From: Frank Chang

Date: 11 Jun, 2010 15:31:25

Message: 3 of 4

On Jun 11, 11:27 am, "Sadik " <sadik.h...@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. :)

Subject: finding the row number

From: Matt Fig

Date: 11 Jun, 2010 15:47:04

Message: 4 of 4

find(~any(M,2))

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us