Where is the zero?

2 vues (au cours des 30 derniers jours)
IBM watson
IBM watson le 9 Nov 2018
Commenté : IBM watson le 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

Réponse acceptée

madhan ravi
madhan ravi le 9 Nov 2018
Modifié(e) : madhan ravi le 9 Nov 2018
a=[ 1 3 5 6 34 4 0 1 3 4 50]
index=find(a==0)
  4 commentaires
Stephen23
Stephen23 le 9 Nov 2018
Note that often logical indexing is more efficient than using find.
IBM watson
IBM watson le 9 Nov 2018
I will take a look. Thanks :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by