.

 This may prove useful:
  siz=size(X);  k=100;  Uim=reshape(U(:,1:k),[siz(1:end-1) k ]);

 USAGE
  [ Yk, Xhat, avsq ] = pcaApply( X, U, mu, k )

 INPUTS
  X           - data for which to get PCA coefficients
  U           - returned by pca.m
  mu          - returned by pca.m
  k           - number of principal coordinates to approximate X with

 OUTPUTS
  Yk          - first k coordinates of X in column space of U
  Xhat        - approximation of X corresponding to Yk
  avsq        - mea