 clear all;
 close all;

 %readtheclassdatafiles
 [num1,txt1,raw1]=xlsread(hardwood.csv);
 [num2,txt2,raw2]=xlsread(carpet.csv);

 %[num1,txt1,raw1]=xlsread(biltmore31.csv);
 %[num2,txt2,raw2]=xlsread(MyPrismacolors1.csv);
 % shuffle the observations of a class randomly
 rand(seed,129);
 nd1=randperm(1024);


 % select the observation corresponding to

 % the first 4 indexes
 t1=num1(nd1(1:4),:);


 % shuffle the observations of a class randomly
 rand(seed,131);


 % select the observation corresponding to

 % the first 4 indexes
 nd2=randperm(1024);
 t2=num2(nd2(1:4),:);


 % collect the values of the 48th feature
 x1=[t1(:,48);t2(:,48)];


 % collect the values of the 49th feature
 x2=[t1(:,49);t2(:,49)];


 % center them w.r.t their means
 xx1=x1-mean(x1);
 xx2=x2-mean(x2);


 % concatenate them
 xx=[xx1;xx2];


 % plot the observations
 figure;plot(xx1,xx2,.,MarkerSize,14);
 grid on;xlabel(Feature 48);ylabel(Feature 49);


 % calculate covariance matrix
 C=(xx*xx)/(length(xx)-1);


 % calculate eigenvector (principal component)

 % and eigenvalue
 [ww,ee]=eig(C);


 % transform using principal compoments
 yy=ww*xx;


 % plot the original and pc-transformed values
 figure;plot(xx1,xx2,.,MarkerSize,14);
 hold on;plot(yy(1,:),yy(2,:),r.,MarkerSize,14);
 grid on;xlabel(PC 1);ylabel(PC 2);