returning Position in Array or Matrices for max()
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello
I'm wondering if there is a trick which can give you back the position (which row and which column) in matrices in which the max value is. max() only gives you the value.
thanks for your help.
Matthias
0 commentaires
Réponse acceptée
Walter Roberson
le 1 Fév 2012
[maxval, maxidx] = max(YourMatrix(:));
[row, col] = ind2sub(size(YourMatrix), maxidx);
0 commentaires
Plus de réponses (1)
Jan
le 1 Fév 2012
No, max() doe give you more than just the value. See:
help max
doc max
Looking in the documentation is a good idea - always.
0 commentaires
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!