Move matrix rows and columns

2 Ansichten (letzte 30 Tage)
Amir Ehsani
Amir Ehsani am 27 Okt. 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]

Akzeptierte Antwort

Matt J
Matt J am 27 Okt. 2012
B=reshape(A.',[],1);
  2 Kommentare
Matt J
Matt J am 27 Okt. 2012
Bearbeitet: Matt J am 27 Okt. 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 am 27 Okt. 2012
Thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by