Move matrix rows and columns

2 views (last 30 days)
Amir Ehsani
Amir Ehsani on 27 Oct 2012
I have a n*n matrix. I want to convert it to n^2*1 matrix. for example: A=[a b;c d] result B=[a;b;c;d]

Accepted Answer

Matt J
Matt J on 27 Oct 2012
B=reshape(A.',[],1);
  2 Comments
Matt J
Matt J on 27 Oct 2012
Edited: Matt J on 27 Oct 2012
It would be better if you organized your a b c d data column-wise in A instead of row-wise. Then you wouldn't have to transpose A, which is expensive. Also, you could just do
B=A(:);

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!