# How do I create and combine column matrices from lists

I need to input the following list of values for x and y , each as a column matrix (7-row, 1-column). Then, combine the two into a 2 x 7 column matrix. I'm new to Mathematica. Please help. How do I do this? Thank you.

x = 1.13 | 2.56 | 3.42 | 4.75 | 5.39 | 6.84 | 7.25
y = 3.83 | 4.15 | 3.79 | 1.78 | 0.23 | −0.76 |  −1.25

• You could just input them as a list (e.g. x = {1.13, ..., 7.25}) and Transpose x and y afterwards. May 17 at 22:53

Mathematica uses the list for almost everything. You can think of a list as a row for now for purposes of making matrices.

So when you write {{1,2,3,4},{5,6,7,2}} then this is a matrix of two rows.

To convert this to matrix of 2 columns, you transpose it. So by transposing at the end, you are telling Mathematica, these rows are really columns.

Transpose[{{1, 2, 3, 4}, {5, 6, 7, 2}}] So always start with the idea that lists are rows. To do what you want for your data:

x = {1.13, 2.56, 3.42, 4.75, 5.39, 6.84, 7.25}
y = {3.83, 4.15, 3.79, 1.78, 0.23, -0.76, -1.25}
mat = {x, y} The above is matrix with 2 rows. But you want these to be columns, not rows. Then do an extra step

mat = Transpose[mat] You'll see this alot in Mathematica when working with matrices. You construct the matrix as rows, since that is the natural way for Mathematica, then add a transpose at the end. This is a little different from Matlab.

• Thank you Nasser. I get it now from your explanation. May 18 at 13:52
• (+1) and a minor comment for completeness: Thread@mat is equivalent to the Transpose@mat
– bmf
May 18 at 17:17