array rearrangement

조회 수: 5 (최근 30일)
darksideofthemoon101
darksideofthemoon101 2011년 4월 8일
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