Move matrix rows and columns

2 ビュー (過去 30 日間)
Amir Ehsani
Amir Ehsani 2012 年 10 月 27 日
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]

採用された回答

Matt J
Matt J 2012 年 10 月 27 日
B=reshape(A.',[],1);
  2 件のコメント
Matt J
Matt J 2012 年 10 月 27 日
編集済み: Matt J 2012 年 10 月 27 日
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 2012 年 10 月 27 日
Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by