maximum position of element in a matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi I have a 1000x1000 matrix. I want to find the location and the value of the highest value in the matrix?
댓글 수: 0
채택된 답변
Richard Brown
2012년 4월 11일
Pretty straightforward - the only complicating factor is that max only works down one dimension at a time, so you either have to call it twice or turn the matrix temporarily into a vector. Probably easiest is this:
M = rand(1000);
[maxVal, idx] = max(M(:));
idx is a linear index. If you want the row/column index then
[i, j] = ind2sub(size(M), idx);
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
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!