필터 지우기
필터 지우기

How to use ind2sub in this problem

조회 수: 5 (최근 30일)
Coupe Honda
Coupe Honda 2017년 1월 31일
댓글: Coupe Honda 2017년 2월 1일
A=1000*sin(reshape(10:999, 30, 33));
Use “max(A(:))” to find the index of the column vector which contains the maximum value, and then convert this vector index of A(:) back to the corresponding matrix index (i; j).you can use ind2sub if you wish.

채택된 답변

Niels
Niels 2017년 2월 1일
편집: Niels 2017년 2월 1일
you dont need to use ind2sub if you use max...
copied from doc max
[M,I] = max(...) finds the indices of the maximum values of A and returns them in output vector I, using any of the input arguments in the previous syntaxes. If the maximum value occurs more than once, then max returns the index corresponding to the first occurrence.
A=1000*sin(reshape(10:999, 30, 33));
[maxA,indexA]=max(A(:));
j=ceil(indexA/size(A,1));
i=mod(indexA,size(A,1));
if i==0
i=size(A,1);
end
A(indexA)
A(i,j)
should be your desired maximum
or the boring solution:
[i,j] = ind2sub(size(A),indexA);
ind2sub uses modulo as well

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by