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:
indices of a zero value in an array

Subject: indices of a zero value in an array

From: Snow White

Date: 10 Jul, 2009 10:45:04

Message: 1 of 4

Hello,

Could anyone tell me how to find the indices of a zero value in an array?

Regards,

Subject: indices of a zero value in an array

From: tpl@eng.cam.ac.uk (Tim Love)

Date: 10 Jul, 2009 11:00:00

Message: 2 of 4

"Snow White" <gulesaman@gmail.com> writes:

>Hello,

>Could anyone tell me how to find the indices of a zero value in an array?
Try typing
  help find

Subject: indices of a zero value in an array

From: Snow White

Date: 10 Jul, 2009 12:06:01

Message: 3 of 4

but that is for non zero values
tpl@eng.cam.ac.uk (Tim Love) wrote in message <h376vg$7am$1@gemini.csx.cam.ac.uk>...
> "Snow White" <gulesaman@gmail.com> writes:
>
> >Hello,
>
> >Could anyone tell me how to find the indices of a zero value in an array?
> Try typing
> help find

Subject: indices of a zero value in an array

From: tpl@eng.cam.ac.uk (Tim Love)

Date: 10 Jul, 2009 12:21:04

Message: 4 of 4

"Snow White" <gulesaman@gmail.com> writes:

>but [find] is for non zero values
If you have (for example)
  A=[ 2 0 8 7 0 0 1]
then yes,
  find(A)
will give the indices of the non-zero values, but
  A==0
will give you a result the same size as A with 1 (i.e. true)
where the element of A is zero, and 0 (false) elsewhere. So
  find(A==0)
should give you what you want. So will
  find(not(A))

Tags for 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