% clusterdemo.m - clustering algorithm demonstration program % (C) copyright 2001 by Yu Hen Hu % mfiles used: datagen.m clear all, clf % generate some data using datagen.m, kmeansf.m % Nvec: (1xclass) # data in each of the c gaussian distr. % mean_var: % 3 x class: mean (1st 2 rows) and variance of each class. % 4 x class: mean (1st 2 rows) and variance 1 and variance 2 % 5 x class: mean (1st 2 rows), var 1, var 2, and rotation angle % rotation angle is in [0 90) Nvec=[100 100 100]; mean_var=[... 0.2 0.2 1.0 0.2 1.2 0.8 0.02 0.02 0.03 0.1 0.1 0.03 60 60 0]; x=datagen(Nvec,mean_var); % x is 150 x 2 Wtrue=mean_var(1:2,:)'; figure(1),plot(x(:,1),x(:,2),'.r',Wtrue(:,1),Wtrue(:,2),'ob') legend('data points','True cluster centers') % apply kmeansf.m to the data % Input - W: initial weight vectors c by N matrix, c: # of clusters % - X: K by N input vectors to be clustered % - er: 0