array rearrangement

3 次查看(过去 30 天)
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

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by