Borrar filtros
Borrar filtros

array rearrangement

2 visualizaciones (últimos 30 días)
darksideofthemoon101
darksideofthemoon101 el 8 de Abr. de 2011
Hi,
I have an array of MxN numbers, and I want to rearrange it so that the numbers are all in one column:
1 2 4 5 3 6 7 8
becomes
1 3 2 6 4 7 5 8
How can I do this for an array of any size?
Thanks,
Richard

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 8 de Abr. de 2011
A = A(:); %column-wise extractivon
or for more fancy manipulations:
doc permute
doc transpose
doc reshape
  1 comentario
Walter Roberson
Walter Roberson el 8 de Abr. de 2011
Right general principle, but the code would have to be
reshape(A.',[],1)
or
reshape(A.', numel(A), 1)
or
A = A.';
A(:)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays 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