squareform
"tovector"
)"tomatrix"
)Interchange between distance matrix and distance vector formats.
Converts between an hollow (diagonal filled with zeros), square, and symmetric matrix and a vector with 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 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 distance matrix, it must be square and the diagonal entries
of x must all be zeros. squareform
will generate a warning if
x is not symmetric.
The second argument is used to specify the output type in case there
is a single element. It will defaults to "tomatrix"
otherwise.
See also: pdist
Source Code: squareform