listing only the first index
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
shobhit mehrotra
le 10 Fév 2015
Réponse apportée : Hikaru
le 10 Fév 2015
I have a matrix
A= [ 1 3 5 7 33 23 44 55 55]
I want to find the index of the maximum value, so I used this line
A= find( A == max(A(:)))
However this displays both indices (8 & 9) since they both have a value of 55, however I want it to only list the first index, 8. How would I go about that?
Thanks
0 commentaires
Réponse acceptée
Hikaru
le 10 Fév 2015
The function max alone is sufficient, you don't have to use find for this sort of problem.
[Y,I] = max(A)
The variable I will return the index of the first maximum value.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!