returning Position in Array or Matrices for max()
8 次查看(过去 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!