Path: news.mathworks.com!not-for-mail
From: "John D'Errico" <woodchips@rochester.rr.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Vectorization of Euclidean distance calculation
Date: Sat, 8 Nov 2008 23:58:02 +0000 (UTC)
Organization: John D'Errico (1-3LEW5R)
Lines: 19
Message-ID: <gf5929$djl$1@fred.mathworks.com>
References: <gf568c$ft5$1@fred.mathworks.com>
Reply-To: "John D'Errico" <woodchips@rochester.rr.com>
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 1226188682 13941 172.30.248.38 (8 Nov 2008 23:58:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 8 Nov 2008 23:58:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869215
Xref: news.mathworks.com comp.soft-sys.matlab:499695


"Arvind Iyer" <aiyer@ict.usc.edu> wrote in message <gf568c$ft5$1@fred.mathworks.com>...
> The norm command provides a quick way of calculating Euclidean distance in an N-dimensional space.
> e.g,
> N = 50;
> x1 = randn(1,N);
> x2 = randn(1,N);
> euclid_dist = norm(x1-x2);
> 
> Consider I have a M points x1, x2.....xM stored in an MxN matrix
> [x1;x2.....;xM]
> I now want to find the Euclidean distance of each of these point from a test point xT.
> 
> How can this be done in a vectorized way without loops?
> I am interested in speeding this up because M is really large in my problem.


http://www.mathworks.com/matlabcentral/fileexchange/18937

John