qslazio
Full Member level 3
a simple script segment to do FFT for a tone plus additive white noise.
nbpts = 32768;
fs = 1e3*nbpts;
nbprds = 7;
fi = fs/nbpts*nbprds;
amplitude = 1;
pnoise = 1e-6;
noise = random('norm',0,sqrt(pnoise),1,nbpts);
signal = amplitude*sin(2*pi*fi/fs*[0:nbpts-1]) + noise;
Sxx = abs(fft(signal)./nbpts).^2;
Snn = abs(fft(noise)./nbpts).^2;
Pn_wi_signal = sum(Sxx) - 0.5*amplitude^2
Pn_wo_signal = sum(Snn)
After running above script, you can seen that Pn_wi_signal is not equal to Pn_wo_signal. Pn_wo_signal is direct FFT to the noise itself.
Pn_wi_signal (varies a lot) is much larger than Pn_wo_signal which is right.
Anyone knows what's wrong with Pn_wi_signal?
Thanks a lot!
nbpts = 32768;
fs = 1e3*nbpts;
nbprds = 7;
fi = fs/nbpts*nbprds;
amplitude = 1;
pnoise = 1e-6;
noise = random('norm',0,sqrt(pnoise),1,nbpts);
signal = amplitude*sin(2*pi*fi/fs*[0:nbpts-1]) + noise;
Sxx = abs(fft(signal)./nbpts).^2;
Snn = abs(fft(noise)./nbpts).^2;
Pn_wi_signal = sum(Sxx) - 0.5*amplitude^2
Pn_wo_signal = sum(Snn)
After running above script, you can seen that Pn_wi_signal is not equal to Pn_wo_signal. Pn_wo_signal is direct FFT to the noise itself.
Pn_wi_signal (varies a lot) is much larger than Pn_wo_signal which is right.
Anyone knows what's wrong with Pn_wi_signal?
Thanks a lot!