HOW CAN I SORTED MY MATRIX DESCEND

I HAVE A MATRIX M=[ 1 2 3 4 5 ;1 20 54 6 40] I WANT TO SORT MY MATRIX WITHIN THE SECOND COLON WITH ASCENDING WAY TO OBTEIND THIS RESULT :
M=[3 5 2 4 1;54 40 20 6 1]
HOW CAN I DO

 採用された回答

Andrei Bobrov
Andrei Bobrov 2015 年 11 月 22 日
編集済み: Andrei Bobrov 2015 年 11 月 22 日

0 投票

M=[ 1 2 3 4 5 ;1 20 54 6 40];
[~,ii] = sort(M(2,:),'descend');
out = M(:,ii);
or
out = sortrows(M',-2)';

1 件のコメント

ali hadjer
ali hadjer 2015 年 11 月 22 日
thank you i use out = sortrows(M',-2)'; its good :)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

質問済み:

2015 年 11 月 22 日

コメント済み:

2015 年 11 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by