4
$\begingroup$

I have two lists, and I want to merge them for ListPlot3D.

First, I made a list of {x,y} points for lx=0.3; ly=0.3; dx=0.1; dy=0.1

grid = Table[{{i, j}}, {i, 0, lx, dx}, {j, 0, ly, dy}]

(* {{{{0., 0.}}, {{0., 0.1}}, {{0., 0.2}}, {{0., 0.3}}}, {{{0.1, 0.}},
{{0.1, 0.1}}, {{0.1, 0.2}}, {{0.1, 0.3}}}, {{{0.2, 0.}}, {{0.2, 0.1}},
{{0.2, 0.2}}, {{0.2, 0.3}}}, {{{0.3, 0.}}, {{0.3, 0.1}}, {{0.3, 0.2}}, {{0.3, 0.3}}}}
 *)

The values are given

v={113.864, 99.4164, 90.5971, 85.1589, 72.8399, 85.7906, 68.1644, 58.7077, 50.1663, 
   72.0986, 52.0997, 42.4192, 37.144, 66.1972, 44.6466, 34.9181}

How can I merge two lists and get new={0, 0, 113.864}, {0, 0.1, 99.4164}...

$\endgroup$

2 Answers 2

2
$\begingroup$

Try this:

ListPlot3D[
 Join[
  Flatten[grid, {{1, 2}, {3, 4}}],
  Partition[v, {1}],
  2
  ]
 ]
$\endgroup$
1
$\begingroup$

Using SubsetMap (new in 12.0) with appended zeros as placeholders for replacement

SubsetMap[v &, Append[0] /@ Flatten[grid, 2], {All, -1}];

ListPlot3D[%]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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