% Copyright 2009 The MathWorks, Inc.
% Standardize the measurements from each observation so that we're looking
% at relative sizes.
meas0 = meas ./ repmat(sqrt(sum(meas.^2, 2)),1,4);
% Plot each observation as a single line consisting of four points. That's
% known as a parallel coordinates plot.
h = plot(meas0');
% Color the data from each cluster differently.
set(h(clustIdx==1),'Color',[1 .7 .7]);
set(h(clustIdx==2),'Color',[.7 1 .7]);
set(h(clustIdx==3),'Color',[.7 .7 1]);
% Label the plot.
[dum,i] = unique(clustIdx);
legend(h(i),'Cluster 1', 'Cluster 2', 'Cluster 3');
varnames = {'Sepal Length','Sepal Width','Petal Length','Petal Width'};
set(gca,'Xlim',[.9 4.1],'XTick',1:4,'XTickLabel',varnames)
title('K-Means Clustering of Fisher''s Iris Data');
% Label the misclassified specimens.
misses = [67 71 73 84 85];
hold on; plot(meas0(misses,:)', 'k.-'); hold off