Re: combine a list of lists with another list of lists
- To: mathgroup at smc.vnet.net
- Subject: [mg40908] Re: combine a list of lists with another list of lists
- From: Oliver Ruebenkoenig <ruebenko at imtek.uni-freiburg.de>
- Date: Wed, 23 Apr 2003 05:18:35 -0400 (EDT)
- Organization: Rechenzentrum der Universitaet Freiburg, Germany
- References: <b858o8$5s6$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Sean, On Wed, 23 Apr 2003, sean kim wrote: > 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}}} zLst = {{z1, z2, z3}, {z4, z5, z6}, {z7, z8, z9}}; xyLst = {{{x1, y1}, {x1, y2}, {x1, y3}}, {{x2, y1}, {x2, y2}, {x2, y3}}, {{x3, y1}, {x3, y2}, {x3, y3}}}; to understand the solution go step by step: Flatten[ zLst ] // MatrixForm Flatten[xyLst, 1 ] // MatrixForm MapThread[ List, { Flatten[ xyLst, 1 ], Flatten[ zLst ] } ] next: MapThread[ Join[ #1, { #2 } ] &, { Flatten[ xyLst, 1 ], Flatten[ zLst ] } ] final: data = Partition[ MapThread[ Join[ #1, { #2 } ] &, { Flatten[ xyLst, 1 ], Flatten[ zLst ] } ], 3 ] > 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? ListPlot3D[ # ] & /@ data is your friend. hope that helps, oliver Oliver Ruebenkoenig, <ruebenko at imtek.de> Phone: ++49 +761 203 7293