0

I have a simple sinus signal with some noise. If I try a simple FFT algorithm I get the amplitude of the signal(23) and the freq(2). If I try the pwelch from Matlab with hanning window I am getting the right freq but the amplitude is wrong. How can I obtain the real amplitude? This is the code I am using for the pwelch:

time = 0:0.01:50;
frequency = 2;
amplitude = 23;
y = amplitude * sin (2 * pi * frequency * time);
y= y + 6 * randn(size(time));
y = y - mean(y);
N = length(y);
Fs = 100;
NFFT = 2^nextpow2(N);
M = 4396;
w = hanning(M);
[Pyy,Fy] = pwelch(y, w,[],M,Fs);
plot(Fy,Pyy);
Stewie Griffin
  • 14,889
  • 11
  • 39
  • 70
Razvan
  • 3
  • 5

1 Answers1

1

IMHO, you cannot due to the spectral leakage. If you see the Hanning window that you are using, it is a low pass filter (when centred and normalised). It will reduce the power at the main frequencies and it will introduce power at other frequencies, i.e. smoothing. But, it is an aperiodic signal with infinite duration in the frequency domain, which cannot be computed.

figure; 
plot(w);
title(['Hanning window with ', num2str(M), 'points']);

enter image description here

You can read more here.

tashuhka
  • 5,028
  • 4
  • 45
  • 64
  • but how can I apply a hann window on a signal and get the right amplitude and the right freq? a series of hann windows and overlap them and do an average of the fft – Razvan Oct 15 '14 at 16:48