I would like to find the 10 largest values in a 90x90 matrix, and their indices. Any suggestions? Thanks, Yaniv

 채택된 답변

Ced
Ced 2016년 4월 10일
편집: Ced 2016년 4월 10일

5 개 추천

A = randn(90);
Nmax = 10; % get Nmax biggest entries
[ Avec, Ind ] = sort(A(:),1,'descend');
max_values = Avec(1:Nmax);
[ ind_row, ind_col ] = ind2sub(size(A),Ind(1:Nmax)); % fetch indices
You can of course also use a while loop and pick out one value at a time.

댓글 수: 1

Yaniv
Yaniv 2016년 4월 10일
Looks great, exactly what I needed. Thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

태그

질문:

2016년 4월 10일

댓글:

2016년 4월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by