# How to add an extra column to a current matrix (list)? [duplicate]

a = {{-800, 1712}, {-801, 1713}, {-806, 1832}}
TableForm[a]
b = a[[All, 2]] - Min[a[[All, 2]]]


How do I make a new matrix (list) whic looks like this

-800  1712 0
-801  1713 1
-806  1832 120


The 3rd column, takes the difference between the value from the 2nd column and it's minimum of the whole 2nd column.

I tried to Join the two, but with no success.

Thanks.

Perhaps I've missed something, but you seem to just want to append a vector (which you have already calculated) to a matrix.

Documentation for Append[] shows how to do it:

For your case since you already have a and b:

MapThread[Append, {a, b}] // MatrixForm


A different approach enables you to join matrixes to make longer rows:

The following makes a 2 column matrix from your b

b2 = Transpose[{b, b}];
b2 // MatrixForm


The documentation for Join[] shows the way to do what you asked for in your comment:

Note that the 2 at the end of the Join[] operates as a level specification.

Join[a, b2, 2];

• How would I Append two columns? Do I have to use MapThread[Append, { MapThread[Append, {a, b}], b} ] // TableForm, or there is an easy way? Thanks. – Chen Stats Yu Dec 6 '14 at 16:34