SELECTING MATRIX ELEMENTS IN DESCENDING ORDER

4 ビュー (過去 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)
  1 件のコメント
Mathieu NOE
Mathieu NOE 2021 年 12 月 17 日
hello
problem solved?

サインインしてコメントする。


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 Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by