Reputation: 14660
Is there any built in MATLAB command that "stretches" out a multidimensional array into a linear array?
e.g [1,2;3,4] should be come [1,2,3,4]
Upvotes: 0
Views: 827
Reputation: 27027
The reshape
command can do this:
x = [1 2; 3 4];
y = reshape(x, 1, []);
The empty array []
indicates that MATLAB should calculate automatically how many elements should go in that direction (i.e., that you won't have to specify the number of elements in your array).
Upvotes: 1