returning Position in Array or Matrices for max()
10 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Walter Roberson
2012 年 2 月 1 日
[maxval, maxidx] = max(YourMatrix(:));
[row, col] = ind2sub(size(YourMatrix), maxidx);
0 件のコメント
その他の回答 (1 件)
Jan
2012 年 2 月 1 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!