% compute PCA by centering and SVD % included here since matlab's princomp % is not available in all installations function [X,V,D,mn] = pca(A) [m,n] = size(A); mn = mean(A); X = A - repmat(mn, m, 1); [U,S,V] = svd(X,'econ'); X = X*V; D = diag(S); D = D.^2 / (m-1); D = diag(D); end