pdist
              Return the distance between any two rows in X.
 D = pdist (X calculates the euclidean distance between
 pairs of observations in X.  X must be an  numeric
 matrix representing  points in -dimensional space.  This
 function computes the pairwise distances returned in D as an
  row vector.  Use Z = squareform (D) to
 convert the row vector D into a an  symmetric matrix Z,
 where Z(i,j) corresponds to the pairwise distance between
 points i and j.
 D = pdist (X, Y, Distance) returns the
 distance between pairs of observations in X using the metric specified
 by Distance, which can be any of the following options.
| "euclidean" | Euclidean distance. | |
| "squaredeuclidean" | Squared Euclidean distance. | |
| "seuclidean" | standardized Euclidean distance. Each coordinate difference between the rows in X and the query matrix Y is scaled by dividing by the corresponding element of the standard deviation computed from X. A different scaling vector can be specified with the subsequent DistParameter input argument. | |
| "mahalanobis" | Mahalanobis distance, computed using a positive definite covariance matrix. A different covariance matrix can be specified with the subsequent DistParameter input argument. | |
| "cityblock" | City block distance. | |
| "minkowski" | Minkowski distance. The default exponent is 2. A different exponent can be specified with the subsequent DistParameter input argument. | |
| "chebychev" | Chebychev distance (maximum coordinate difference). | |
| "cosine" | One minus the cosine of the included angle between points (treated as vectors). | |
| "correlation" | One minus the sample linear correlation between observations (treated as sequences of values). | |
| "hamming" | Hamming distance, which is the percentage of coordinates that differ. | |
| "jaccard" | One minus the Jaccard coefficient, which is the percentage of nonzero coordinates that differ. | |
| "spearman" | One minus the sample Spearman’s rank correlation between observations (treated as sequences of values). | |
| @distfun | Custom distance function handle.  A distance
 function of the form function D2 = distfun (XI, YI),
 where XI is a  vector containing a single observation in
 -dimensional space, YI is an  matrix containing an
 arbitrary number of observations in the same -dimensional space, and
 D2 is an  vector of distances, where(D2k)is
 the distance between observations XI and(YIk,:). | 
 D = pdist (X, Y, Distance, DistParameter)
 returns the distance using the metric specified by Distance and
 DistParameter.  The latter one can only be specified when the selected
 Distance is "seuclidean", "minkowski", and
 "mahalanobis".
See also: pdist2, squareform, linkage
Source Code: pdist