Return value of fft function and details of the bins

11 ビュー (過去 30 日間)
Mahesh
Mahesh 2014 年 1 月 14 日
編集済み: Wesley Ooms 2014 年 2 月 3 日
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

回答 (2 件)

Wesley Ooms
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 件のコメント
Wesley Ooms
Wesley Ooms 2014 年 1 月 14 日
If ~odd(N) doesn't work, you van use 1-rem(N,2) or 1-mod(N,2).

サインインしてコメントする。


Matt J
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 件のコメント
Mahesh
Mahesh 2014 年 1 月 14 日
Thanks Matt. I have some more doubts . If I am taking samples with 512 samples per second . and do fft for a one second signal . fft will return me 512 bins.Could you please let me know whether my understanding is correct .
returned bins will contain 1/2 the details of frequency components with maximum 1/2 the sampling frequency . first 256 bins will contain real part of the frequency component . Next 256 will contain the imaginary part ? My confusion is how this will be ordered in the bin
Matt J
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 ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by