|
"Cesare " <cmfornewsgroup@gmail.com> wrote in message <heebg8$f26$1@fred.mathworks.com>...
> Hi!
> I'm playing with matlab princomp for performing PCA. I'm breaking a random signal into its component and then I'm trying to reconstruct it using all the components. I'd expect an almost perfect reconstruction, however I notice big difference between the original and reconstructed signal. Below is the code, am I doing something wrong or is it a numerical problem?
> Thanks a lot in advance,
> Cesare
>
> CODE ============================================
>
>
> clear
> clc
>
> % Number of points:
> Npt = 100;
> % Number of trials:
> Ntr = 20;
> dat = rand(Npt, Ntr);
> [COEFF,SCORE,latent] = princomp(dat.');
>
> %% Reconstructing
> tr = 10; % trial that we are trying to reconstruct
> reconstructed_sig = zeros(Npt,1);
> for comp=1:Npt
> reconstructed_sig(:) = reconstructed_sig(:) + SCORE(tr,comp) * COEFF(:,comp);
> end
>
> %% Plotting
> figure
> hold all
> plot(dat(:,tr) - mean(dat(:,tr)));
> plot(reconstructed_sig)
Ok, to better restate the question:
suppose I record 30 repetition of the same stochastic time-signal of length 100. In this case I have 100 random variables and 30 trials. Then the input to princomp is a matrix of size 40-by-100? So that each column of coeff represents one of the extracted components in my time signal?
Thanks,
Cesare
|