Return value of fft function and details of the bins
11 ビュー (過去 30 日間)
古いコメントを表示
HI, I am a new to matlab and fft() .
Could you please help me in understudying the return value(data structure) of fft function in terms of the frequency bins. I was not able to find a proper explanation of bins .
regards Mahesh
0 件のコメント
回答 (2 件)
Wesley Ooms
2014 年 1 月 14 日
編集済み: Wesley Ooms
2014 年 2 月 3 日
The bins are slightly different between even and odd number of sample points. I use the following:
f = ceil(-N/2:N/2-1)/dt/N ; % frequency points
where N is the number of sample points and dt sample time. You can check this with for example a multisinus with its frequency an integer number uf the base frequency and without a window:
N = 11112 ; % number of samples
dt = 1e-4 ; % sample time
t = dt*(0:N-1) ; % time points
f = [-N/2:-1 ~odd(N):N/2]/dt/N; % frequency points
freqs = f(f>100&f<1000) ; % frequencys in the signal
its = 1:length(freqs) ; % iterations
phase = its.^2*pi/1e3 ; % phase of frequencys in the signal (schroeder phase)
a = 0 ; % DC offset
for i=its
a=a+cos(2*pi*freqs(i)*t+phase(i));
end
b=fftshift(fft(a));
subplot(311),plot(t,a ,'-')
subplot(312),plot(f,abs (b),'.')
subplot(313),plot(f,angle(b),'.')
1 件のコメント
Matt J
2014 年 1 月 14 日
編集済み: Matt J
2014 年 1 月 14 日
If you are sampling time at intervals T seconds, the frequency samples will be (k-1)/(N*T) Hz, where k=1,...,N and X(k) is the output of your fft.
2 件のコメント
Matt J
2014 年 1 月 14 日
編集済み: Matt J
2014 年 1 月 14 日
Yes, the fft will return 512 bins spaced apart by 1 Hz. The first half of the samples will correspond to positive frequencies in the continuous Fourier domain and the second half of the samples will be negative frequencies.
If you apply fftshift() to the output of fft then the samples will be re-ordered so that negative frequencies are on the left. The corresponding continuous space frequency sample axis will then be,
frequencyAxis= ((0:N-1) -ceil((N-1)/2))*Fs/N;
i.e., with DC at frequencyAxis(257).
参考
カテゴリ
Help Center および File Exchange で Fourier Analysis and Filtering についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!