SELECTING MATRIX ELEMENTS IN DESCENDING ORDER

조회 수: 1 (최근 30일)
HEMRAJ PATEL
HEMRAJ PATEL 2021년 12월 7일
댓글: Mathieu NOE 2021년 12월 17일
I WANT A PROGRAMME WHERE NUMBERS ARE SELECTED IN DESCENDING ORDER WITH THEIR INDICES (i,j) .
DO NOT ARRANGE THE MATRIX OR CHANGE ANYTHING IN MATRIX.
I JUST WANT SELECTION OF ELEMENTS IN DESCENDING ORDER.
THANKS.
A=[57 60 62 64 69 67 68 63 36 33;
52 45 25 37 49 55 58 49 39 34;
53 45 25 37 48 56 58 50 39 39;
56 48 41 76 159 164 153 158 171 130;
52 47 41 78 123 166 154 154 179 133;
39 43 41 41 45 64 95 93 74 73;
45 43 39 50 52 63 103 86 73 80;
45 35 13 17 30 36 62 54 34 30;
43 34 13 20 31 35 62 51 34 31;
18 19 15 39 85 97 115 78 24 23]
  댓글 수: 1
Jan
Jan 2021년 12월 7일
Do not:
3. Use all caps or SHOUT in your posts
Thanks.

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

답변 (2개)

Mathieu NOE
Mathieu NOE 2021년 12월 7일
hello
try this
r = row index
c = col index
[value,ind] = sort(A(:),1,'descend');
[r,c] = ind2sub(size(A),ind)

Jan
Jan 2021년 12월 7일
편집: Jan 2021년 12월 7일
This can be obtained by the 2nd output of the sort() command.
A=[57 60 62 64 69 67 68 63 36 33;
52 45 25 37 49 55 58 49 39 34;
53 45 25 37 48 56 58 50 39 39;
56 48 41 76 159 164 153 158 171 130;
52 47 41 78 123 166 154 154 179 133;
39 43 41 41 45 64 95 93 74 73;
45 43 39 50 52 63 103 86 73 80;
45 35 13 17 30 36 62 54 34 30;
43 34 13 20 31 35 62 51 34 31;
18 19 15 39 85 97 115 78 24 23];
[~, index] = sort(A(:), 'descend'); % [EDITED] 'descend' as 2nd input
[row,col] = ind2sub(size(A), index)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by