Code covered by the BSD License  

Highlights from
Distance Matrix

5.0

5.0 | 3 ratings Rate this file 32 Downloads (last 30 days) File Size: 2.4 KB File ID: #15145
image thumbnail

Distance Matrix

by Joseph Kirk

 

29 May 2007 (Updated 29 May 2007)

fast, vectorized distance matrix calculation

| Watch this File

File Information
Description

Returns the point-to-point distance between all pairs of points (similar to PDIST in the Statistics Toolbox, for those without it)
 
DMAT = DISTMAT(XY) Calculates the distance matrix using an automatic option
DMAT = DISTMAT(XY,OPT) Uses the specified option to compute the distance matrix
[DMAT,OPT] = DISTMAT(XY) Also returns the automatic option used by the function
 
Inputs:
XY is an NxP matrix of coordinates for N points in P dimensions
OPT (optional) is an integer between 1 and 4 representing the chosen method for computing the distance matrix (see note below)
 
Outputs:
DMAT is an NxN matrix, where the value of DMAT(i,j) corresponds to the distance from XY(i,:) to XY(j,:)
OPT (optional) is an integer between 1 and 4 representing the method used to compute the distance matrix (see note below)
 
Note:
DISTMAT contains 4 methods for computing the distance matrix
 OPT=1 Usually fastest for small inputs. Takes advantage of the symmetric property of distance matrices to perform half as many calculations
 OPT=2 Usually fastest for medium inputs. Uses a fully vectorized method
 OPT=3 Usually fastest for large inputs. Uses a partially vectorized method with relatively small memory requirement
 OPT=4 Another compact calculation, but usually slower than the others

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
05 Jun 2007 Siyi Deng

Good implementation. Nice examples and screen shots.

06 Jun 2007 Jon Dattorro

For more methods of fast computation of distance matrices, see the book:
Convex Optimization & Euclidean Distance Geometry, Dattorro
http://convexoptimization.com

29 Jun 2007 Nina Hendrarini  
17 Nov 2010 Peter Nave  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
distance matrix Joseph Kirk 22 Oct 2008 09:14:03
pdist Joseph Kirk 22 Oct 2008 09:14:03
mathematics Joseph Kirk 22 Oct 2008 09:14:03
pointtopoint Joseph Kirk 22 Oct 2008 09:14:03
distance matrix Bo 09 Jun 2009 23:49:54
distance matrix Barun Bairagi 04 Nov 2011 03:53:13

Contact us at files@mathworks.com