Matrix to array and array to matrix conversion

Is there a one line command in GAUSS to convert a matrix to array or an array to a matrix?

(For example,vec2mat command in matlab converts an array into a matrix and A=A(:) converts a matrix into an column vector)

Thanks.

1 Answer



0



accepted

There are a few functions for this sort of transformation. Here are a few examples. Let us know if you have any questions about them.

//Create a 2x3 matrix
A = { 1 2 3,
      4 5 6 };

//Convert to a 2x3 array
A_2darray = mattoarray(A);

//Convert 2x3 array to 2x3 matrix
Amat = arraytomat(A_2darray);

//Convert to a 2x1x3 array
A_3darray = areshape(A, 2 | 1 | 3);

//Create column vector
//from 'A' by row
A_vec = vecr(A);

aptech

1,773

Your Answer

1 Answer

0
accepted

There are a few functions for this sort of transformation. Here are a few examples. Let us know if you have any questions about them.

//Create a 2x3 matrix
A = { 1 2 3,
      4 5 6 };

//Convert to a 2x3 array
A_2darray = mattoarray(A);

//Convert 2x3 array to 2x3 matrix
Amat = arraytomat(A_2darray);

//Convert to a 2x1x3 array
A_3darray = areshape(A, 2 | 1 | 3);

//Create column vector
//from 'A' by row
A_vec = vecr(A);


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.