Re: finding positions of elements in a list
- To: mathgroup at smc.vnet.net
- Subject: [mg86791] Re: [mg86761] finding positions of elements in a list
- From: Curtis Osterhoudt <cfo at lanl.gov>
- Date: Fri, 21 Mar 2008 01:53:00 -0500 (EST)
- Organization: LANL
- References: <200803200755.CAA29380@smc.vnet.net>
- Reply-to: cfo at lanl.gov
Hi, Peter, Select is my first approach. Note that I stuck some values into "mylist" for which the y-coordinates are less than 80, just to test: In[29]:= mylist = {{20, 109}, {20, 110}, {22, 18}, {20, 111}, {21, 105}, {21, 106}, {21, 107}, {22, 34}, {21, 12}} Out[29]= {{20, 109}, {20, 110}, {22, 18}, {20, 111}, {21, 105}, {21, 106}, {21, 107}, {22, 34}, {21, 12}} In[30]:= myNewList = Select[mylist, #1[[2]] > 80 & ] Out[30]= {{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, 107}} Hope that helps! C.O. On Thursday 20 March 2008 01:55:37 PeterM wrote: > Hi. > > Having a few problems here with what I think should be a simple operation. > I have a list as shown: > > mylist={{20, 109}, {20, 110}, {20, 111}, {21, 105}, {21, 106}, {21, > 107},...} > > It's a list of {x,y} co-ordinates of some data points I'm analysing. > > I want to create a new list which contains only those data points whose y > co-ordinate is greater than 80 ie. mylist[[n,2]]>80. > > Problem is, I can't work out how to use Select to do this when each element > in the list has an x and a y co-ordinate. If I split the list into x and y > co-ordinates and searched for those y values greater than 80, I would have > a list of those y-values but would not know the corresponding x-values. > > I also tried Position but it wasn't clear to me if a pattern can be used > for this. > > Thanks in advance, Pete. -- ========================================================== Curtis Osterhoudt cfo at remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html ==========================================================
- References:
- finding positions of elements in a list
- From: PeterM <metaxas@lps.u-psud.fr>
- finding positions of elements in a list