RE: combine a list of lists with another list of lists
- To: mathgroup at smc.vnet.net
- Subject: [mg40918] RE: [mg40898] combine a list of lists with another list of lists
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Thu, 24 Apr 2003 05:25:43 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
>-----Original Message----- >From: sean kim [mailto:shawn_s_kim at yahoo.com] To: mathgroup at smc.vnet.net >Sent: Wednesday, April 23, 2003 7:19 AM >To: mathgroup at smc.vnet.net >Subject: [mg40918] [mg40898] combine a list of lists with another list of lists > > >I have a bit of list operation problem. > >let's say we have two lists, one list of lists of z values over time. >then another list of lists of x and y values over time > >as follows for example, > >{{z1, z2, z3}, {z4, z5, z6}, {z7, z8, z9}} > >the number of the lists withing this list varies in actual problem > >also condsider the following list of lists. > > >{{{x1, y1}, {x1, y2}, {x1, y3}}, > {{x2, y1}, {x2, y2}, {x2, y3}}, > {{x3, y1}, {x3, y2}, {x3, y3}}} > >now i would like to generate a new list that is of the form {xn, yn, >zn} such that it can be plotted using ListPlot command > >as.. > >{{{x1, y1, z1}, {x1, y2, z2}, {x1, y3, z3}}, > {{x2, y1, z4}, {x2, y2, z5}, {x2, y3, z6}}, > {{x3, y1, z7}, {x3, y2,z8}, {x3, y3,z9}}} > >but it seems to me listplot3D will only plot if it's a single list of >lists of xyz values. not multiple lists of lists as i have defined >above. > >how can I first generate a new list using the preexisting list of lists >as above and then plot them? > > [...] Sean, to generate the list In[1]:= ztt = Partition[Table[Unique["z"], {9}], 3] Out[1]= {{z1, z2, z3}, {z4, z5, z6}, {z7, z8, z9}} In[2]:= xytt = Transpose[ Outer[List, Table[Unique["x"], {3}], Table[Unique["y"], {3}]]] Out[2]= {{{x1, y1}, {x2, y1}, {x3, y1}}, {{x1, y2}, {x2, y2}, {x3, y2}}, {{x1, y3}, {x2, y3}, {x3, y3}}} In[3]:= MapThread[Append, {xytt, ztt}, 2] Out[3]= {{{x1, y1, z1}, {x2, y1, z2}, {x3, y1, z3}}, {{x1, y2, z4}, {x2, y2, z5}, {x3, y2, z6}}, {{x1, y3, z7}, {x2, y3, z8}, {x3, y3, z9}}} To Plot see, e.g.: In[11]:= zz = Plot3D[Sin[x y]Cos[y], {x, 0, 5}, {y, 0, 3}, PlotPoints -> {21, 13}][[1]]; In[12]:= Dimensions[zz] Out[12]= {13, 21} We combine that with a new grid In[13]:= grid = Table[ With[{x = N[5 Log[10, x]], y = N[3 Log[10, y]]}, {x, y}], {y, 1, 10, 9/12}, {x, 1, 10, 9/20}]; In[14]:= Dimensions[grid] Out[14]= {13, 21, 2} In[15]:= xyz = MapThread[Append, {grid, zz}, 2] In[16]:= << Graphics`Graphics3D` In[17]:= ListSurfacePlot3D[xyz, Axes -> True, BoxRatios -> {1, 1, .4}] -- Hartmut Wolf