计算FFT时的信号长度 [英] the Length of signal in calculating FFT
问题描述
我想问一些与我的最后一个问题有关的问题,所以我不想在另一个主题中发帖.我的问题包含一个代码,因此我不能将其发布为注释.因此,我必须将我的旧问题修改为一个新问题.请看一下并提供帮助.谢谢.
I want to ask some questions related to the last question of mine so I don't want to post in another thread. My question contains a code, I therefore can't post it as a comment. So I have to edit my old question into a new one. Please take a look and help. Thank you.
我是FFT和DSP的新手,我想问一些关于在Matlab中计算FFT的问题.以下代码来自Matlab帮助,我刚刚消除了噪音.
I'm 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.
-
我可以选择不同于NFFT的信号L的长度吗?
Can I choose the length of signal L different from NFFT?
我不确定是否正确使用了window.但是,当我使用window(在下面的代码中进行改进)时,我无法获得振幅的确切值吗?
I'm not sure if I used window correctly. But when I use window (hanning in the following code), I can't get the exact values of amplitudes?
当L和NFFT获得不同的值时,幅度值也将不同.如何获得输入信号幅度的准确值? (在下面的代码中,我使用了一个已知的信号来检查代码是否正常工作.但是,以防万一,我从传感器获得了信号,但我不知道其幅度,如何检查?)
When L and NFFT get different values, then the values of amplitudes were different too. How can I get the exact value of amplitude of input signal? (in the following code, I used a already known signal to check if the code work correctly. But in case, I got the signal from a sensor and I dont know ahead its amplitude, how can I check?)
非常感谢您,并期待您的来信:)
I thank you very much and look forward to hearing 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.
推荐答案
您需要应用窗口函数之前,以获取与采样窗口内周期数不是整数的频率分量一致的结果.
You need to apply a window function prior to the FFT to get consistent results with frequency components that have non-integral number of periods within your sampling window.
您可能还需要考虑使用周期图而不是直接使用FFT-它会为您提供窗口功能以及许多其他内部服务.
You might also want to consider using periodogram instead of using the FFT directly - it takes care of window functions and a lot of the other housekeeping for you.
这篇关于计算FFT时的信号长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!