Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have a two lists: list1 = {{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}, {x5, y5}} and list2 = {z1, z2, z3, z4, z5} and I want to make a third one like this output = {{x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}, {x4, y4,z4}, {x5, y5, z5}} What nice command can do the trick? It is to do a ListPlot3D with two lists with more than 10000 entries. I tried with Map and pure function but it is giving me troubles. Thank you

share|improve this question

marked as duplicate by Kuba, Öskå, Michael E2, ciao, m_goldberg Jun 13 '14 at 22:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

You want to add a column to the existing matrix. Try to look for such statement in old posts here. – Kuba Jun 13 '14 at 15:32
MapThread[Append, {list1, list2}] – andre Jun 13 '14 at 15:42
I recommend taking a look at ArrayReshape, see e.g. this question How to partition a list in a specific way? – Artes Jun 13 '14 at 15:54
up vote 2 down vote accepted

Try this


or this

MapThread[{#1[[1]], #1[[2]], #2} &, {list1, list2}]
share|improve this answer
Thanks, I will use the MapThread, it is nice! – lambertmular Jun 13 '14 at 16:08
Transpose[Join @@ {Transpose@list1, {list2}}]


Join @@@ Transpose[{list1, List /@ list2}]


Transpose[{Sequence @@ Transpose@list1, list2}]


ArrayReshape[{list1, list2}, Dimensions[list1] + {0, 1}]

(* {{x1,y1,z1},{x2,y2,z2},{x3,y3,z3},{x4,y4,z4},{x5,y5,z5}} *)
share|improve this answer

With the last parameter of Join:

Join[list1, List /@ list2, 2]
share|improve this answer
Flatten /@ MapThread[List, {list1, list2}]


MapThread[Append, {list1, list2}]


Thread[f[list1, list2]] /. f -> Append
share|improve this answer

Here is another one, with MapIndexed

 MapIndexed[ {list1[[Last@#2,1]],list1[[Last@#2,2]],#1},list2]
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.