%  pca
clear
%
a=[2 1 3 6]' % input matrix
b=[3 2  1 2]' % input matrix
%
xm=[mean(a).*ones(length(a),1) mean(b).*ones(length(b),1)]
x=[ a b]-xm
cx=cov(x)
[r,lamda,q]=svd(cx) % find eigenvalues, eigenvectors
v=x*r % pca 
cov(v)
xr=xm+v*r' % reconstructed data




