Signal length when calculating FFT

I want to ask a few questions related to the last question, so I do not want to post to another thread. My question contains code, so I cannot post it as a comment. Therefore, I must change my old question to a new one. Please take a look and help. Thank.

I am new to FFT and DSP, and I want to ask you some questions about calculating FFT in Matlab. The following code is from Matlab help, I just removed the noise.

  • Can I choose a signal length L other than NFFT?

  • I am not sure if I used the window correctly. But when I use the window (hanning in the following code), I can not get the exact values ​​of the amplitudes?

  • When L and NFFT get different values, the amplitudes are also different. How can I get the exact value of the amplitude of the input signal? (In the following code, I used the already known signal to check whether the code works correctly. But in case I received a signal from the sensor and I don’t know its amplitude, how can I check?)

I really thank you and hope to hear from you :)

Fs = 1000;                    % Sampling frequency
T = 1/Fs;                     % Sample time
L = 512;                     % Length of signal
NFFT=1024;                   % number of fft points
t = (0:L-1)*T;                % Time vector
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);    input signal
X = fft(hann(L).*x', NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
plot(f,2*abs(X(1:NFFT/2+1)))     % Plot single-sided amplitude spectrum.
+5
source share
2 answers

You need to apply the window function before FFT to get consistent results with frequency components that have an integer number of periods in your sample window.

periodogram FFT - .

+1

All Articles