MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Combining Lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16782] Re: Combining Lists
  • From: "Stephen P Luttrell" <luttrell at signal.dra.hmg.gb>
  • Date: Wed, 24 Mar 1999 17:07:10 -0500
  • Organization: Defence Evaluation and Research Agency
  • References: <7d9rot$7pe@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

JOHN C ERB wrote in message <7d9rot$7pe at smc.vnet.net>...
>I have a set of x & y data points in one list;
>
>xydata={{x1,y1},{x2,y2},{x3,y3},{x4,y4}};
>
>and a corresponding set of z data points in another list:
>
>zdata={z1,z2,z3,z4};
>
>I wish to combine them into one list of {x,y,z} data points,
>which I can do by:
>
>{temp1,temp2}=Transpose[xydata];
>xyzdata=Transpose[{temp1,temp2,zdata}]
>
>which gives the desired result:
>
>{{x1,y1,z1},{x2,y2,z2},{x3,y3,z3},{x4,y4,z4}}
>
>QUESTION:  Is there a more efficient way of doing this?


This is a slicker way of doing what you want:

xydata={{x1,y1},{x2,y2},{x3,y3},{x4,y4}};
zdata={z1,z2,z3,z4};
MapThread[Append[#1,#2]&,{xydata,zdata}]

Stephen P Luttrell
Signal Processing and Imagery Department
DERA Malvern, St.Andrew's Road
Malvern, United Kingdom, WR14 3PS

+44 (0)1684 894046 (tel)
+44 (0)1684 894384 (fax)
luttrell at signal.dera.gov.uk (email)




  • Prev by Date: Re: Write: space between numbers in a line
  • Next by Date: Simplify: Which Sign
  • Previous by thread: Re: Combining Lists
  • Next by thread: DSolve Error Message