Home > hfrc > matlab > utility > dist.m

dist

PURPOSE ^

DIST - computes distance in between points in euclidean space.

SYNOPSIS ^

function d = dist( x1, y1, x2, y2 )

DESCRIPTION ^

 DIST - computes distance in between points in euclidean space.

 Usage: d = dist( x1, y1, x2, y2 )
        d = dist( x1, x2 )

 For the first form, x1 and y1 must have the same size.  The same goes
 for x2 and y2.  x1 and x2 can either have the same size, or one can be a
 row vector and the other a column vector. In the prior case, the
 Euclidean distance in the plane is calculated between [x1,y1] and 
 [x2,y2].  In the second case, the distance between all possible point
 pairs is calculated (ie. if x1 is a row vector of length N and x2 is a
 column vector of length M, the result will be a matrix of size NxM with
 the distance between all possible combinations of [x1, y1] and [x2,y2].  

 The second case is computationally equivalent to 
        d = dist( x1, 0 * x1, x2, 0 * x2 )
 and is a slow, but legitimate way of computing distance on the line.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

     $Id: dist.m,v 1.4 2003-04-02 01:00:45 dmk Exp $    

 Copyright (C) 2001 David M. Kaplan
 Licence: GPL

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Mon 18-Dec-2006 07:26:46 by m2html © 2003