Write MatLab commands to find the index of the max value in the bold area of A
조회 수: 1 (최근 30일)
이전 댓글 표시
I also need to find find the index of the maximum value in the bold area of A.
A>>
7.24 0.80 *7.31* *9.24* *3.09*
1.06 0.06 *8.97* *1.37* *0.55*
8.67 8.88 *9.92* *0.71* *0.90*
3.45 9.01 *9.15* *4.80* *2.29*
4.56 5.16 *5.33* *7.10* *7.61*
1.16 0.64 *0.08* *8.76* *8.06*
8.96 6.23 *9.96* *6.93* *7.71*
8.15 6.84 *6.95* *1.88* *7.36*
4.75 1.54 0.28 3.10 9.04
2.95 8.42 2.33 1.38 4.39
2.28 4.74 7.54 7.94 3.73
7.48 3.01 7.61 8.38 4.85
I tried to do B=find(A(1:8,3:5>2 & 1:8,3:5<=6)) but I not sure if the command is the right one here to find the values in the bold area and [m,n]=max(max(A(1:8,3:5))
댓글 수: 0
답변 (2개)
Walter Roberson
2012년 11월 30일
T = A(1:8, 3:5);
[m, idx] = max(T(:));
[r, c] = idx2sub(size(T), idx);
B = [r, c+2];
This would leave B in [row column] format relative to A. You weren't clear as to the form of the index you wanted, and you weren't clear if you wanted the index within the sub-array or within all of A.
댓글 수: 3
Walter Roberson
2012년 11월 30일
That's what my code calculates, in row and column form. If you want it in scalar index form then probably the easiest way would be to use
B = sub2idx(size(A), r, c);
Andrei Bobrov
2012년 11월 30일
편집: Andrei Bobrov
2012년 11월 30일
variant
B = -inf(size(A));
B(1:8,3:5) = A(1:8,3:5);
[m,n] = find(abs(B - max(B(:))) < eps(100));
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!