Gargob
Gargob

Reputation: 251

Matlab turning vectors into a matrix

I don't know exactly how to phrase this question, but I have 3 column vectors, and I'm trying to turn them into a matrix such that, the matrix would basically look like [v1 v2 v2]

where the length of each vector is obviously more than 1.

Is there an automatic way to do this?

Right now, I'm going

matrix{1} = v1;
matrix{2} = v2;
matrix{3} = v3;

but this doesn't work work, because when I print out my matrix I get

matrix = 

    [50x1 double]    [50x1 double]    [50x1 double]

instead of the actual numbers.

Upvotes: 2

Views: 3305

Answers (1)

user1726343
user1726343

Reputation:

Let's say your column vectors are defined as:

>>v1 = [1; 2; 3];
>>v2 = [4; 5; 6];
>>v3 = [7; 8; 9];

Then your matrix is simply a row vector of these columns:

>>m = [v1 v2 v3];

Upvotes: 5

Related Questions