MathGroup Archive 2000

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

Search the Archive

Re: Need to reduce 2 lists so that only {x,y} pairs with same x remain


Dear Chuck,

Try
{newdata1, newdata2} =
   Transpose[Select[Split[Union[data1,data2], 
#1[[1]]==#2[[1]]&],Length[#]>1&]];
newdata1
newdata2

Hope this helps, Reinhard



>Hello,
>
>I have 2 lists of data:
>
>for example
>data1={{1,1},{1.5,1.5},{2,2},{3,3},{4,4},{5,5}}
>
>data2={{1,2},{2,3},{3,4},{4,5},{6,7},{7,8}}
>
>
>I want to do a point by point comparision, so I
>need to reduce both data1 and data2 so that
>common x data in the {x,y} pairs for each list
>remain.
>
>Thus the lists should look like this:
>
>data1={{1,1},{2,2},{3,3},{4,4}}
>data2={{1,2},{2,3},{3,4},{4,5}}
>
>What function(s) would to something like this?
>
>Thanks,
>
>Chuck
>
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.

********************************************
              Dr. Reinhard Simonovits
Handelsakademie  |  Karl Franzens University
Math Department  |  Inst. of Th. Physics
Grazbachgasse 71 |  Universitaetsplatz 5
               A-8010 Graz, Austria

Email: Reinhard.Simonovits at kfunigraz.ac.at
*********************************************



  • Prev by Date: Re: Need to reduce 2 lists so that only {x,y} pairs with same x remain
  • Next by Date: Re: Integration...
  • Previous by thread: Re: Need to reduce 2 lists so that only {x,y} pairs with same x remain
  • Next by thread: Re: Need to reduce 2 lists so that only {x,y} pairs with same x remain