% pca.m % copyright (c) 1997 by Yu Hen Hu % a demonstration of principal component analysis to synthesized data % data are generated using dgen2.m % then projected into two eigenvectors and displayed % created: 10/9/97 clear all; clf mv=[-1 .5; -.5 .5; 0.2 0.1] x=dgen2([30 20],mv); plot(x(:,1),x(:,2),'o'); [v,d]=eig(x'*x); y1=x*v(:,1)*v(:,1)'; y2=x*v(:,2)*v(:,2)'; plot(x(:,1),x(:,2),'o',y1(:,1),y1(:,2),'x',y2(:,1),y2(:,2),'*')