user1711832
user1711832

Reputation: 13

How to convert 1D vector to 2D vector and user defined rows and columns in matlab?

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:

2dA = 1Dto2D(A,5,2);

and I get

2dA = [ 1 2 3 4 5
        6 7 8 9 10]

Upvotes: 1

Views: 579

Answers (1)

aganders3
aganders3

Reputation: 5945

Yes, you are looking for the reshape function. It works exactly as you have described.

Upvotes: 1

Related Questions