Effacer les filtres
Effacer les filtres

How to find vector indexes without for loops

1 vue (au cours des 30 derniers jours)
Hamid Bakht
Hamid Bakht le 30 Nov 2016
i have a vector matrix for example [20,3,56,7,8,96,52,22] and i have another value x=8. now i wanna find the index number of x in that vector without using for or while loop thank you for your help
  1 commentaire
David Goodmanson
David Goodmanson le 30 Nov 2016
Hi Hamid, take a look at the 'find' function

Connectez-vous pour commenter.

Réponses (1)

Guillaume
Guillaume le 30 Nov 2016
[~, index] = ismember(8, [20, 3, 56, 7, 8, 96, 52, 22]);
or
index = find([20, 3, 56, 7, 8, 96, 52, 22] == 8);
  1 commentaire
Hamid Bakht
Hamid Bakht le 30 Nov 2016
thank you so much really helped

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Indexing 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