Path: news.mathworks.com!not-for-mail
From: "John Vendt" <a@B.dot.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Find nearest index
Date: Tue, 31 Jul 2007 19:03:41 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 17
Message-ID: <f8o12d$jcv$1@fred.mathworks.com>
References: <f8mjkc$m3i$1@fred.mathworks.com> <f8n5ki$k3u$1@fred.mathworks.com>
Reply-To: "John Vendt" <a@B.dot.com>
NNTP-Posting-Host: webapp-00-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1185908621 19871 172.30.248.35 (31 Jul 2007 19:03:41 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 31 Jul 2007 19:03:41 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1070757
Xref: news.mathworks.com comp.soft-sys.matlab:421927


"us " <us@neurol.unizh.ch> wrote in message <f8n5ki$k3u$1@fred.mathworks.com>...
> Sven:
> <SNIP in search of proximity...
> 
> one of the many other solutions
> 
> % some data
>      n=[50 150 200];
>      m=[40 65 130 201 -10 199];
> % the engine
>      [ix,ix]=min(abs(bsxfun(@minus,m,n.')));
> % the result
>      ix
> 
> us

I just tested this a bit and it seems a standard bisection search seems to be a lot faster if n (and, to less extent, m) are large...