Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24189] Re: Need to reduce 2 lists so that only {x,y} pairs with same x remain
  • From: dkeith at sarif.com
  • Date: Wed, 28 Jun 2000 22:51:09 -0400 (EDT)
  • References: <8jc73k$dg3@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Chuck,

This function accepts the two lists and returns a list of two lists
whose x values are contained in the set intersection of the x values of
the two lists.

commonX[list1_, list2_] := Select[#, MemberQ[Intersection[list1
[[All,1]], list2[[All, 1]]],
#[[1]]] &] & /@ {list1, list2}


In article <8jc73k$dg3 at smc.vnet.net>,
  materialsscientist at my-deja.com wrote:
> 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.
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


  • Prev by Date: Re: Annoying "Hand"/"Glove" in Mathematica 4 for Linux
  • Next by Date: Re: Need to reduce 2 lists so that only {x,y} pairs with same x remain
  • 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