How to reshape a matrix using sort

Hi Everyone,
I have a matrix 25x68, each cell is either 1 or 0. I would like to reorder the matrix so that it is sorted according to the columns which has the most number of 1. Can someone help?
I will also like to reorder the label (x values) accordingly.
Thanks!

1 件のコメント

José-Luis
José-Luis 2017 年 8 月 22 日
編集済み: José-Luis 2017 年 8 月 22 日
Just note that this is not what reshape means. Rearrange might be a better word.

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

 採用された回答

Stephen23
Stephen23 2017 年 8 月 22 日

1 投票

>> M = randi([0,1],25,68);
>> [~,idx] = sort(sum(M,1));
>> cellplot(M(:,idx))
and use the index on the labels as well.

その他の回答 (0 件)

カテゴリ

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

タグ

質問済み:

2017 年 8 月 22 日

編集済み:

2017 年 8 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by