필터 지우기
필터 지우기

finding n maximum elements in a matrix

조회 수: 3 (최근 30일)
jenka
jenka 2017년 2월 6일
편집: John Chilleri 2017년 2월 6일
Hi all, I have a symmetrical matrix of size mxm with diagonal elements equal to one. The values range [-1,1]. I would like to find five off the diagonal maximum elements in that matrix and return col and row indices. So far I have the following. It does not really work for values < 0. Any suggestions:
corrMat=rho - eye(size(rho));
A=corrMat;
sortedValues = unique(A(:));
maxValues = sortedValues(end-4:end);
  댓글 수: 3
the cyclist
the cyclist 2017년 2월 6일
Also, do you want to select both the above- and below-diagonal instance of the maximal elements? Since the matrix is symmetric, there will always be pairs.
John Chilleri
John Chilleri 2017년 2월 6일
편집: John Chilleri 2017년 2월 6일
If you want to base "maximum" on magnitude, then perhaps insert an
A = abs(corrMat); % A = corrMat;
but this will fail with the unique function if there is an equivalent negative/positive value.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by