I am trying to write a PCA function in MATLAB. I know that there is the function princomp, I just wanted to understand the process for myself. One problem I've encountered is that the eig matrix calculation on the covariance matrix is incorrect. I have this covariance matrix:
matCov =
0.6166 0.6154
0.6154 0.7166
And when I call the eig function, I get:
eVec =
-0.7352 0.6779
0.6779 0.7352
Whereas, with the function princomp I get:
eVec =
-0.7352 -0.6779
0.6779 -0.7352
I know that it's the same, but each time I calculate the eigenvectors matrix (ordered by decreasing variance values) using the princomp function and the eigfunction, the last column of the eigVectors matrix are different. Can anyone explain this?