| Statistics Toolbox | Search  Help Desk |
| cluster | Examples See Also |
Construct clusters from linkage output.
Syntax
T = cluster(Z,cutoff) T = cluster(Z,cutoff,depth)
Description
cluster(Z,cutoff) constructs clusters from hierarchical cluster tree, Z, generated by the linkage function. Z is a matrix of size m-1 by 3, where m is the number of observations in the original data.
cutoff is a threshold value that determines how the cluster function creates clusters. The value of cutoff determines how cluster interprets it.cluster(Z,cutoff,depth)constructs clusters from cluster tree Z. The depth argument specifies the number of levels in the hierarchical cluster tree to include in the inconsistency coefficient computation. (The inconsistency coefficient compares a link between two objects in the cluster tree with neighboring links up to a specified depth. See the inconsistent function for more information.) When the depth argument is specified, cutoff is always interpreted as the inconsistency coefficient threshold.
The output, T, is a vector of size m that identifies, by number, the cluster in which each object was grouped. To find out which object from the original dataset are contained in cluster i, use find(T==i).
Example
The example uses thepdist function to calculate the distance between items in a matrix of random numbers and then uses the linkage function to compute the hierarchical cluster tree based on the matrix. The output of the linkage function is passed to the cluster function. The cutoff value 3 indicates that you want to group the items into three clusters. The example uses the find function to list all the items grouped into cluster 2.
rand('seed', 0);
X = [rand(10,3); rand(10,3)+1; rand(10,3)+2];
Y = pdist(X);
Z = linkage(Y);
T = cluster(Z,3);
find(T == 3)
ans =
11
12
13
14
15
16
17
18
19
20
See Also
clusterdata, cophenet, dendrogram, inconsistent, linkage, pdist, squareform