squareform
statistics: zOut = squareform (yIn)
statistics: yOut = squareform (zIn)
statistics: zOut = squareform (yIn, 'tovector')
statistics: yOut = squareform (zIn, 'tomatrix')
Interchange between distance matrix and distance vector formats.
Converts between a hollow (diagonal filled with zeros), square, and symmetric matrix and a vector of the lower triangular part.
Its target application is the conversion of the vector returned by
pdist into a distance matrix. It performs the opposite operation
if input is a matrix.
If x is a numeric or logical vector, its number of elements must fit
into the triangular part of a matrix (main diagonal excluded). In other
words, numel (x) = n * (n - 1) / 2 for some integer
n. The resulting matrix will be n by n.
If x is a numeric or logical distance matrix, it must be square and the diagonal entries of x must all be zeros. If x is not symmetric, only the lower triangular part is used.
The second argument is used to specify the output type in case the distance
input is a scalar. Accepted values are 'tomatrix' (or 'tom')
and 'tovector' (or 'tov'). If not specified, it defaults to
"tomatrix" otherwise.
See also: pdist
Source Code: squareform