Rearrange matrix into single row

13 次查看(过去 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]?

采纳的回答

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 CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by