Reshape - columnwise. any command to linewise?
18 views (last 30 days)
Show older comments
help reshape
RESHAPE Reshape array.
RESHAPE(X,M,N) returns the M-by-N matrix whose elements are taken columnwise from X.
I need some way to turn a matrix linewise instead.
0 Comments
Accepted Answer
Andrei Bobrov
on 29 Nov 2011
reshape(X.',M,N).'
8 Comments
Loïc Niederhauser
on 26 Apr 2022
Also, what if I want to reshape to a 3d matrix? Is there anyway to just work row major in matlab?
Bruno Luong
on 26 Apr 2022
Loic -Hi btw ;-) - you could use permute for ND-array (there is also pagetranspose command more restrictive)
X=randi(9,[6 5])
permute(reshape(X.',[size(X,2) 2 3]),[2 1 3])
More Answers (0)
See Also
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!