Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.fr>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to find a list of floats in another list of floats
Date: Mon, 11 Feb 2008 11:39:02 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 12
Message-ID: <fopc4m$1rm$1@fred.mathworks.com>
References: <47af565c$0$1103$4c368faf@roadrunner.com> <fopb6l$mdk$1@fred.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.fr>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1202729942 1910 172.30.248.35 (11 Feb 2008 11:39:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 11 Feb 2008 11:39:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:450536


One among many solutions:

A=rand(1,3);
B=rand(1,50);

[Bsorted I J]=unique(B);
inearest=I(interp1(Bsorted,(1:length(Bsorted)),A,...
           'nearest','extrap'));

A - B(inearest)

Bruno