FUNCTION REFERENCE

pdist

Condensed distances between pairs of observation rows.

Condensed distances between pairs of observation rows.

Syntax

D = pdist(X,metric,parameter)

The default metric is 'euclidean'. Other metrics: 'squaredeuclidean', 'seuclidean' (optional standard deviations), 'mahalanobis' (optional positive-definite covariance), 'cityblock', 'minkowski' (optional positive P, default 2), 'chebychev', 'cosine', 'correlation', 'spearman' (average tied ranks), 'hamming', 'jaccard', or @(xi,XJ) returning one column. Default scale and covariance use complete rows of X. D is a row in pair order (1,2),(1,3),...,(1,m),(2,3),...,(m-1,m). Pairs involving NaN have NaN distance.

Example

d = pdist([0 0;3 4;3 0]);   % [5 3 4]

Differences from MATLAB: Real two-dimensional data only; no fast-distance variants or cache options. Mahalanobis uses Cholesky solves. Pair counts and workspace are bounded before allocation; cancellation is checked between row chunks.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.