Move matrix rows and columns

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]

 Risposta accettata

Matt J
Matt J il 27 Ott 2012
B=reshape(A.',[],1);

2 Commenti

Matt J
Matt J il 27 Ott 2012
Modificato: Matt J il 27 Ott 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(:);
Amir Ehsani
Amir Ehsani il 27 Ott 2012
Thanks

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by