问题
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]
回答1:
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.
来源:https://stackoverflow.com/questions/26591378/matlab-dft-fft-frequency-range