how to find maximum value in d matrix of size (11*11)
이전 댓글 표시
we have a matrix of size 11*11. can u please send me the matlab code to find maximum value in the matrix as soon as possible.
채택된 답변
추가 답변 (1개)
Image Analyst
2014년 10월 5일
Not sure what "find" means - the value or the location - so I'll find both for you
[maxValue, linIndexOfMax] = max(M(:))
[row, column] = ind2sub(size(M), linIndexOfMax);
For example
M = magic(3)
[maxValue, linIndexOfMax] = max(M(:))
[row, column] = ind2sub(size(M), linIndexOfMax)
In the command window:
M =
8 1 6
3 5 7
4 9 2
maxValue =
9
linIndexOfMax =
6
row =
3
column =
2
댓글 수: 2
Yi
2014년 10월 5일
WOW, that's what I did not know. Thank you for the correction .
Image Analyst
2014년 10월 6일
Here's another quirk that trips people up all the time - it's about the size function as applied to images: http://blogs.mathworks.com/steve/2011/03/22/too-much-information-about-the-size-function/
카테고리
도움말 센터 및 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!