Why different result with PCA and SVD in Matlab?
Date: 2022-11-30 12:20:34
I have implemented my PCA function in Matlab in the following way:
function e = myPCA(X) [D, N] = size(X); m = mean(X, 2); X = X - repmat(m, 1, N); [e, ~, ~] = svd(X,'econ'); end
When I use now the built in Matlab function [e, ~, ~] = pca(X');
I'm getting the same absolute values as with my function but for some columns of U the sign is flipped.
Which ones is the right way to go and why is there this difference in sign?