Re: With Nearest
- To: mathgroup at smc.vnet.net
- Subject: [mg121096] Re: With Nearest
- From: Thomas Dowling <thomasgdowling at gmail.com>
- Date: Sun, 28 Aug 2011 04:04:24 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201108271217.IAA17756@smc.vnet.net>
One possibility using Cases: Cases[#, {_,Alternatives@@ Nearest[#[[All,2]], 20]}]& @ Join[AA, List@{10, 21}] gives {{10,19},{10,21}} Or, using Select: Function[x, Select[x, MemberQ[#,Alternatives@@ Nearest[x[[All,2]], 20]]&]][Join[AA, List@{10, 21}]] -> {{10,19},{10,21}} Tom Dowling On Sat, Aug 27, 2011 at 1:17 PM, graser <graser at gmail.com> wrote: > Dear Mathematica group, > I have a simple question for you. > Let's say there is an array or matrix like > > AA = {{1.3, 1.5}, {21.5, 23.6}, {10, 19}}; > > If I want to extract a list whose second element is close to 20, How > can I do it with Nearest function? > Or is there any other method possible? > ( In this case, the answer should be {10, 19} ) > > Thanks! > > >
- References:
- With Nearest
- From: graser <graser@gmail.com>
- With Nearest