Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to find a list of floats in another list of floats
Date: Sun, 10 Feb 2008 22:45:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 24
Message-ID: <fonupf$7fu$1@fred.mathworks.com>
References: <47af565c$0$1103$4c368faf@roadrunner.com> <fonsi6$bp4$1@fred.mathworks.com> <font4t$ifr$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1202683503 7678 172.30.248.38 (10 Feb 2008 22:45:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 10 Feb 2008 22:45:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:450483


"John D'Errico" <woodchips@rochester.rr.com> wrote in message <font4t$ifr
$1@fred.mathworks.com>...
> As it turns out, using bsxfun can help quite
> a bit here.
> 
> n = 1000;
> A = rand(n,1);B = rand(n,1);
> 
> tic,[x,y] = meshgrid(A,B);d=abs(x-y);toc
> Elapsed time is 0.221196 seconds.
> 
> d = abs(bsxfun(@minus,A,B'));toc
> Elapsed time is 0.072752 seconds.
> 
> Unfortunately, bsxfun appeared only in the
> last release or so. It never has to create
> those intermediate arrays.
> 
> John
--------
  My matlab 4a (1994) is weeping, John!

Roger Stafford