Create silhouette plots from clustered data using different distance metrics.
Generate random sample data.
rng('default') % For reproducibility
X = [randn(10,2)+3;randn(10,2)-3];
Create a scatter plot of the data.
scatter(X(:,1),X(:,2));
title('Randomly Generated Data');
The scatter plot shows that the data appears to be split into two clusters of equal size.
Partition the data into two clusters using kmeans with the default squared Euclidean distance metric.
clust = kmeans(X,2);
clust contains the cluster indices of the data.
Create a silhouette plot from the clustered data using the default squared Euclidean distance metric.
silhouette(X,clust)