returning Position in Array or Matrices for max()

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

 채택된 답변

Walter Roberson
Walter Roberson 2012년 2월 1일

0 개 추천

[maxval, maxidx] = max(YourMatrix(:));
[row, col] = ind2sub(size(YourMatrix), maxidx);

추가 답변 (1개)

Jan
Jan 2012년 2월 1일

0 개 추천

No, max() doe give you more than just the value. See:
help max
doc max
Looking in the documentation is a good idea - always.

카테고리

도움말 센터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!

Translated by