k) * V(:,1:k)' + repmat(mu, n, 1);
  Xrecon = Z(:,1:k)*V(:,1:k)' + repmat(mu, n, 1);
  err = (Xrecon - X);
  mse(ki) = sqrt(mean(err(:).^2));
end
plot(Ks, mse, '-o')
ylabel('mse'); xlabel('K'); title('reconstruction error');
printPmtkFigure(sprintf('pcaImages-%s-recon', name)); 

% Scree plot
figure(4);clf
plot(cumsum(evals)/sum(evals), 'ko-')
ylabel('proportion of variance')
xlabel('K')
printPmtkFigure(sprintf('pcaImages-%s-scree', name)); 


% Plot reconstructed image
ndx = 125; % selected face
Ks = [2 10