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!