Rearrange matrix into single row

19 ビュー (過去 30 日間)
Lanceric Tse
Lanceric Tse 2018 年 8 月 10 日
編集済み: Stephen23 2018 年 8 月 10 日
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]?

採用された回答

Paul Shoemaker
Paul Shoemaker 2018 年 8 月 10 日
reshape(b',1,numel(b)) % Note the transpose ('), this is important.
  1 件のコメント
Stephen23
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
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.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by