returning Position in Array or Matrices for max()
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Walter Roberson
il 1 Feb 2012
[maxval, maxidx] = max(YourMatrix(:));
[row, col] = ind2sub(size(YourMatrix), maxidx);
0 Commenti
Più risposte (1)
Jan
il 1 Feb 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 Commenti
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!