Finding largest values in matrix

조회 수: 8 (최근 30일)
Yaniv
Yaniv 2016년 4월 10일
댓글: Yaniv 2016년 4월 10일
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일
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개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by