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]?
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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!