Path: news.mathworks.com!not-for-mail
From: "us " <us@neurol.unizh.ch>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Find nearest index
Date: Tue, 31 Jul 2007 11:15:31 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 14
Message-ID: <f8n5ki$k3u$1@fred.mathworks.com>
References: <f8mjkc$m3i$1@fred.mathworks.com>
Reply-To: "us " <us@neurol.unizh.ch>
NNTP-Posting-Host: webapp-01-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1185880531 20606 172.30.248.36 (31 Jul 2007 11:15:31 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 31 Jul 2007 11:15:31 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:421835


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