For example, I have 9 variables and 362 cases. I've made PCA calculation, and found out that first 3 PCA coordinates are enough for me.
Now, I have new point in my 9-dimensional structure, and I want to project it to principal component system coordinate. How to get its new coordinates?
[W, Y] = pca(data, 'VariableWeights', 'variance', 'Centered', true);
W = diag(std(data))\W;
[data, mu, sigma] = zscore(data);
sigma(sigma==0) = 1;
x = data(1,:);
x = bsxfun(@minus,x, mu);
x = bsxfun(@rdivide, x, sigma);
y0 = Y(1,:);
y = (W*x')';
sum(abs(y0 - y))
plot(y0,'g'); hold on;
How to get coordinates of a new point projected to new principal component basis?