Move matrix rows and columns

4 vues (au cours des 30 derniers jours)
Amir Ehsani
Amir Ehsani le 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]

Réponse acceptée

Matt J
Matt J le 27 Oct 2012
B=reshape(A.',[],1);
  2 commentaires
Matt J
Matt J le 27 Oct 2012
Modifié(e) : Matt J le 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(:);
Amir Ehsani
Amir Ehsani le 27 Oct 2012
Thanks

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by