About PCA and 'manual' decomposition

If I try to perform a PCA with elementary functions, I use this code (MATLAB 7.10):
load acetylene.mat
dataset = [x1 x2 x3 y];
[M,N]=size(dataset);
mn=mean(dataset,1);
data=dataset-repmat(mn,M,1);
covariance = 1 / (M-1) * (data')*(data);
[PrinComp,L]=eig(covariance);
L=diag(L);
[values,Lind]=sort(-1*L);
PC = PC(:,Lind);
At this point I tried to compare what I've done with: [a,b]=PCA(dataset). Well, eigenvalues are the same, but the matrix is a little bit different (the second column has the opposite signs).
Thanks.

 Accepted Answer

Thorsten
Thorsten on 28 Oct 2015

1 Comment

Thanks. It is just a matter of non-unique solution, but I wonder why, being the same functions...

Sign in to comment.

More Answers (0)

Categories

Products

Asked:

on 28 Oct 2015

Commented:

on 28 Oct 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!