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]

 Respuesta aceptada

Matt J
Matt J el 27 de Oct. de 2012

0 votos

B=reshape(A.',[],1);

2 comentarios

Matt J
Matt J el 27 de Oct. de 2012
Editada: Matt J el 27 de Oct. de 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 el 27 de Oct. de 2012
Thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 27 de Oct. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by