Return value of fft function and details of the bins

조회 수: 17 (최근 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 CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by