git-svn-id: http://moon:8086/svn/matlab/trunk@91 801c6759-fa7c-4059-a304-17956f83a07c
20 lines
508 B
Plaintext
20 lines
508 B
Plaintext
function [xpca xzca] = PCAwhite(x)
|
|
size(x)
|
|
x = x';
|
|
k= 10;
|
|
epsilon=1e-42;
|
|
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;
|
|
|
|
plot(x( |