Reputation: 13
I have a 1x10 1D vector A=1:10; and I want to convert it into a 5x2 2D vector is there any function I can use like:
1x10
A=1:10;
5x2
2dA = 1Dto2D(A,5,2);
and I get
2dA = [ 1 2 3 4 5 6 7 8 9 10]
Upvotes: 1
Views: 579
Reputation: 5945
Yes, you are looking for the reshape function. It works exactly as you have described.
reshape