Borrar filtros
Borrar filtros

How to reshape a matrix using sort

1 visualización (últimos 30 días)
ShaneS
ShaneS el 22 de Ag. de 2017
Editada: José-Luis el 22 de Ag. de 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 comentario
José-Luis
José-Luis el 22 de Ag. de 2017
Editada: José-Luis el 22 de Ag. de 2017
Just note that this is not what reshape means. Rearrange might be a better word.

Iniciar sesión para comentar.

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by