Example
Generating hierarchical cluster trees from sample data
This example shows the use of sample data to generate hierarchical clusters, and a 3-D scatter plot to present the cluster.
Produces the sample data matrix, where the random number is generated by the standard uniform distribution (U (0,1)).
RNG (' Default '); % for Reproducibilty
X = [Gallery (' Uniformdata ', [10 3],12);
Gallery (' Uniformdata ', [10 3],13) +1.2;
Gallery (' Uniformdata ', [10 3],14) +2.5];
Calculates the distance between elements and generates a hierarchical number of clusters from the sample data. Lists all the elements in the second cluster.
T = Clusterdata (X, ' Maxclust ', 3);
Find (T = = 2)
Ans =
11 12 13 14 15 16 17 18 19 20
Plot the data into a graphic, where each category corresponds to a different color.
Scatter3 (X (:, 1), X (:, 2), X (:, 3), 100,t, ' filled ')
Generating hierarchical cluster trees using Ward's linkage
This example shows the use of Ward's linkage to generate hierarchical clustering numbers, and a 3-D scatter plot to present the cluster.
Produces a sample data matrix of 20,000 rows and 3 columns, where the random number is generated by the standard uniform distribution (U (0,1)).
RNG (' Default '); % for Reproducibilty
X = rand (20000,3);
Use Ward's linkage to generate hierarchical clustering trees. Set ' savememory ' to ' on ' to construct the cluster but not to calculate the distance matrix.
c = Clusterdata (X, ' linkage ', ' ward ', ' savememory ', ' on ', ' Maxclust ', 4);
Plot the data into a graphic, where each category corresponds to a different color.
Scatter3 (X (:, 1), X (:, 2), X (:, 3), 10,c)
Help documentation-Translation-statistics toolbox-exploratory Data analysis-cluster analysis-hierarchical Clustering (cluster,clusterdata) ( 2)