MatArray Toolbox
  Go to function:
    Search    Help Desk 
dl2c    Examples   See Also

dl2c is a mex-file that calculates the euclidian distance between the columns of a matrix or between the columns of two matrices.

Syntax

Description

dl2c is a fast mex-file implementation of the euclidian distances between columns. It is useful for the quick calculation of distances in K-means or hierarchical clustering. The gain in time compared to an m-file implementation varies, but is usually at least 4, and over 20 compared to pdist. The result is a simple sum of squares, it is not divided by the number of rows and the square root is not taken.

The first version of the call returns a symmetrical square matrix d whose values are the squared distances between the columns of the matrix a (e.g. d(2,5) is the squared distance between the second and the fifth column of the matrix a, that is sum( (a(:,2)-a(:,5)).^2 )).

The second version returns a linear matrix of distances, in a fashion similar to pdist in the statistic toolbox. The advantage is that no redundant information is stored, hence a gain in space of a factor of about 2. It is possible to obtain the square form with a call to squareform. See the statistic toolbox for more information.

The third version returns the distances between the columns of the matrices a and b. The element d(i,j) is the distance between the vectors a(:,j) and b(:,i)

Examples

See Also

dl2cnan, pdist, squareform



[ Previous | Help Desk | Next ]