MATLAB Answers

Where is the zero?

1 view (last 30 days)
IBM watson
IBM watson on 9 Nov 2018
Commented: IBM watson on 9 Nov 2018
How to find the location of a zero (or a different number) in a vector ?
like :
a=[ 1 3 5 6 34 4 0 1 3 4 50]
=>7

  0 Comments

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 9 Nov 2018
Edited: madhan ravi on 9 Nov 2018
a=[ 1 3 5 6 34 4 0 1 3 4 50]
index=find(a==0)

  4 Comments

Show 1 older comment
madhan ravi
madhan ravi on 9 Nov 2018
Anytime :)
Stephen Cobeldick
Stephen Cobeldick on 9 Nov 2018
Note that often logical indexing is more efficient than using find.
IBM watson
IBM watson on 9 Nov 2018
I will take a look. Thanks :)

Sign in to comment.

More Answers (0)

Tags


Translated by