From the reshape() docs, for the syntax
"The elements in B preserve their columnwise ordering from A."
If you want to "reshape" a vector so that the output matrix is filled along the rows first, you could reverse the requested dimensions in your call to reshape() and then transpose the result:
A2 = reshape([C D], 4, 3)';
I believe this could be generalized to any number of dimensions with a combination of reshape() and permute().
1 Comment
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/558127-convert-a-vector-into-a-matrix-row-wise#comment_921385
Direct link to this comment
https://fr.mathworks.com/matlabcentral/answers/558127-convert-a-vector-into-a-matrix-row-wise#comment_921385
Sign in to comment.