Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4620

Re: With Nearest

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx01.iad01.newshosting.com!newshosting.com!newspump.sol.net!posts.news.twtelecom.net!nnrp2.twtelecom.net!not-for-mail
From Thomas Dowling <thomasgdowling@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: With Nearest
Date Sun, 28 Aug 2011 08:07:16 +0000 (UTC)
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <j3csvk$5lm$1@smc.vnet.net> (permalink)
References <201108271217.IAA17756@smc.vnet.net>
Lines 39
NNTP-Posting-Date 28 Aug 2011 07:09:54 GMT
NNTP-Posting-Host e9345af3.news.twtelecom.net
X-Trace DXC=X1Onj7:Jn2[KUUGJ=jJOWUC_A=>8kQj6]m^eQlV`f18W:Xj>;_IblDPEFiONJ7[GoV0RC?IgS[7M_
X-Complaints-To abuse@twtelecom.net
Xref x330-a1.tempe.blueboxinc.net comp.soft-sys.math.mathematica:4620

Show key headers only | View raw


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@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!
>
>
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: With Nearest Thomas Dowling <thomasgdowling@gmail.com> - 2011-08-28 08:07 +0000

csiph-web