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);