www.pudn.com > snippets(1).rar > project_pca.m, change:2009-10-12,size:269b


function B = project_pca(A, pca)
%
% project matrix A onto a pre-learned PCA basis

[m,n] = size(A);
A = A-repmat(pca.shift,1,n);

% if applicable, use length normalization
if pca.normalized

  for u = 1:n
    A(:,u) = A(:,u)/norm(A(:,u));
  end

end

B = pca.basis*A;