フィルターのクリア

how to sort a matrix?

1 回表示 (過去 30 日間)
Hugo Matias
Hugo Matias 2018 年 12 月 1 日
編集済み: Stephan 2018 年 12 月 1 日
How do i do this:
before:
a=[3 9 5 7;
3 0 1 2;
11 2 0 9];
after:
a=[11 9 9 7;
5 3 3 2;
2 1 0 0;]

回答 (1 件)

Stephan
Stephan 2018 年 12 月 1 日
編集済み: Stephan 2018 年 12 月 1 日
Hi,
try:
>> a = [3 9 5 7; 3 0 1 2; 11 2 0 9]
a =
3 9 5 7
3 0 1 2
11 2 0 9
>> b = reshape(fliplr(sort(reshape(a,1,[]))),4,3)'
b =
11 9 9 7
5 3 3 2
2 1 0 0
Best regards
Stephan

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by