Rearrange matrix into single row
19 ビュー (過去 30 日間)
古いコメントを表示
Hey there, I have a matrix that looks like this
b=1 2 3 4
1 2 3 4
1 2 3 4
What do I have to do to arrange it into a single row vector[ 1 2 3 4 1 2 3 4 1 2 3 4]?
0 件のコメント
採用された回答
Paul Shoemaker
2018 年 8 月 10 日
reshape(b',1,numel(b)) % Note the transpose ('), this is important.
1 件のコメント
Stephen23
2018 年 8 月 10 日
編集済み: Stephen23
2018 年 8 月 10 日
This answer uses complex transpose. See James Tursa's answer for the correct solution for all cases.
その他の回答 (1 件)
James Tursa
2018 年 8 月 10 日
編集済み: James Tursa
2018 年 8 月 10 日
result = reshape(b.',1,[]);
The transpose is needed to get the row values to line up in memory first before doing the reshape.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!