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!