function [xpca xzca] = PCAwhite(x) size(x) x = x'; k= 10; epsilon=1e-6; avg = mean(x, 1) x = x - repmat(avg, size(x, 1), 1); sigma = x * x' / size(x, 2); size(sigma) [U,S,V] = svd(sigma); %xRot = U' * x; % rotated version of the data. %xTilde = U(:,1:k)' * x; % reduced dimension representation of the data, % where k is the number of eigenvectors to keep xpca = diag(1./sqrt(diag(S) + epsilon)) * U' * x; xzca = U * diag(1./sqrt(diag(S) + epsilon)) * U' * x; close all; imagesc(sigma); colorbar figure; imagesc(x,'EraseMode','none',[-1 1]); colorbar figure; imagesc(xpca); colorbar