title: How to project a new point to PCA new basis?
body: <p>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.</p>
  
  <p>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?</p>
  
  <pre><code>%# here is data (362x9)
  load SomeData
  
  [W, Y] = pca(data, 'VariableWeights', 'variance', 'Centered', true);
  
  %# orthonormal coefficient matrix
  W = diag(std(data))\W;
  
  % Getting mean and weights of data (for future data)
  [data, mu, sigma] = zscore(data);
  sigma(sigma==0) = 1;
  
  %# New point in original 9dim system
  %# For example, it is the first point of our input data
  x = data(1,:);
  x = bsxfun(@minus,x, mu);
  x = bsxfun(@rdivide, x, sigma);
  
  %# New coordinates as principal components
  y0 = Y(1,:); %# point we should get in result
  y = (W*x')'; %# our result
  
  %# error
  sum(abs(y0 - y)) %# 142 =&gt; they are not the same point
  
  %# plot
  figure()
  plot(y0,'g'); hold on;
  plot(y,'r');
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/1WlG9.png" alt="enter image description here"></p>
  
  <p>How to get coordinates of a new point projected to new principal component basis?</p>