How to turn a constant vector into a matrix?

Is there a GAUSS function that would allow me to take a vector and
turn it into a matrix with constant values in each column (or row)? For
example, I say I wanted to take the following:

X = 1 2 3

and from the values in X create the matrix

Y = 1 2 3
    1 2 3
    1 2 3
    1 2 3
    1 2 3

1 Answer



0



accepted

You can use the reshape function for this:

//Create a row vector
X = { 1 2 3 };

//Reshape the row vector into a 5x3 matrix
Y = reshape(X, 5, 3);

Now Y will equal:

    1 2 3
    1 2 3
    1 2 3
    1 2 3
    1 2 3

Your Answer

1 Answer

0
accepted

You can use the reshape function for this:

//Create a row vector
X = { 1 2 3 };

//Reshape the row vector into a 5x3 matrix
Y = reshape(X, 5, 3);

Now Y will equal:

    1 2 3
    1 2 3
    1 2 3
    1 2 3
    1 2 3

You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.