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.

 Réponse acceptée

Thorsten
Thorsten le 28 Oct 2015

0 votes

1 commentaire

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by