问题描述
我真的很难理解MATLAB中的fft函数如何工作.根据:
http://www.mathworks.de /help/matlab/math/fast-fourier-transform-fft.html
fs/n是频谱中采样点之间的距离,其中fs是采样频率,n是信号的长度.他们提供的代码确实提取了频率(尽管我不知道为什么),但是根据fft的实现,他们提供了:http://www.mathworks.de/help/matlab/ref /fft.html
光谱中各点之间的距离应为:1/fs.因为不是插入索引j,而是插入j * T,其中T = 1/fs是采样时间,然后您可以计算点之间的距离,该距离不应为fs/n.如果有人能向我解释频域中点之间的距离是什么,为什么会这样,我将非常感激:)
这不是特定于Matlab的问题.关于傅里叶变换和离散傅里叶变换与频率轴的标度/单位之间的关系的问题更多.可以在以下 PDF文档中找到很好的解释.第3页.
[/EDIT]
在两种情况下,频谱上频率点之间的距离均为fs/n
,这是正确的值.如果我们将代码放在 http://www.mathworks.co.uk中/help/matlab/ref/fft.html ,我们有:
>> Fs = 1000; % Sampling frequency
>> T = 1/Fs; % Sample time
>> L = 1000; % Length of signal
>> t = (0:L-1)*T; % Time vector
>> NFFT = 2^nextpow2(L); % Next power of 2 from length of y
>> f = Fs/2*linspace(0,1,NFFT/2+1);
>> f(2)-f(1)
ans = 0.97656
>> Fs/NFFT
ans = 0.97656
您可以仔细检查所有其他f(n+1)-f(n)
,它们都是一样的.
I am really having a hard time to understand how the fft-function in MATLAB works.According to:
http://www.mathworks.de/help/matlab/math/fast-fourier-transform-fft.html
fs/n is the distance between the sampled points in the Spectrum, where fs is the sampling frequency and n is the length of the signal. The code that they present, does extract the frequencies (although I do not know why), but according to the implementation of fft, that they present:
http://www.mathworks.de/help/matlab/ref/fft.html
the distance between the points in the spectrum should rather be: 1/fs. Because instead of the index j one inserts j*T, where T = 1/fs is the sampling time and then you can calculate the distance between the points, which should not be fs/n.
I would really be grateful if someone could explain me what the distance between the points in the frequency domain is and why this is so:)
[EDIT]
This is not a Matlab-specific problem. It is more a problem about the relationship between the Fourier-Transformation and the Discrete-Fourier-Transformation and the scaling/units of the frequency-axis. A pretty good explanation can be found in this PDF-Document at page 3.
[/EDIT]
The distance between the frequency points on the spectrum is fs/n
in both cases, and that is the correct value. If we take the code in http://www.mathworks.co.uk/help/matlab/ref/fft.html, we have:
>> Fs = 1000; % Sampling frequency
>> T = 1/Fs; % Sample time
>> L = 1000; % Length of signal
>> t = (0:L-1)*T; % Time vector
>> NFFT = 2^nextpow2(L); % Next power of 2 from length of y
>> f = Fs/2*linspace(0,1,NFFT/2+1);
>> f(2)-f(1)
ans = 0.97656
>> Fs/NFFT
ans = 0.97656
You can double-check all the other f(n+1)-f(n)
, they're all the same.
这篇关于Matlab,DFT,FFT,频率范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!