Format distance matrix
Z = squareform(y)
y = squareform(Z)
Z = squareform(y,'tovector')
Y = squareform(Z,'tomatrix')
Z = squareform(y), where
a vector as created by the
y into a square, symmetric format
Z(i,j) denotes the distance between the
jth objects in the original data.
y = squareform(Z), where
a square, symmetric matrix with zeros along the diagonal, creates
y containing the
below the diagonal.
y has the same format as the
output from the
Z = squareform(y,'tovector') forces
y as a vector.
Y = squareform(Z,'tomatrix') forces
Z as a matrix.
The last two formats are useful if the input has a single element, so that it is ambiguous whether the input is a vector or square matrix.
y = 1:6 y = 1 2 3 4 5 6 X = [0 1 2 3; 1 0 4 5; 2 4 0 6; 3 5 6 0] X = 0 1 2 3 1 0 4 5 2 4 0 6 3 5 6 0
squareform(y) = X and