How to reshape a matrix using sort

조회 수: 1 (최근 30일)
ShaneS
ShaneS 2017년 8월 22일
편집: José-Luis 2017년 8월 22일
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일
>> M = randi([0,1],25,68);
>> [~,idx] = sort(sum(M,1));
>> cellplot(M(:,idx))
and use the index on the labels as well.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by