How to reshape a matrix using sort
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
ShaneS
am 22 Aug. 2017
Bearbeitet: José-Luis
am 22 Aug. 2017
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 Kommentar
Akzeptierte Antwort
Stephen23
am 22 Aug. 2017
>> M = randi([0,1],25,68);
>> [~,idx] = sort(sum(M,1));
>> cellplot(M(:,idx))
and use the index on the labels as well.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!