What frequency range does fft compute?

조회 수: 26 (최근 30일)
Calvin He
Calvin He 2022년 7월 28일
댓글: Paul 2022년 7월 28일
So according to the documentation, the fft function for a time series of n samples computes the following:
The question is what are the values of k and how is it ordered from the output of fft? Looking at the example code, they truncate the fft output by about a half to get the "positive" frequencies. When I plot out the full fft output without truncating the vector, it appears that the negative frequencies are shown on the right half of the fft output, i.e., values of k would be [0:n/2-1,-n/2:-1] where n>2. Is this correct?
If so, why the offset in the negative frequencies, and what about frequencies for ? Are those frequencies ignored because they are not practical due to the sampling theorem?

채택된 답변

Star Strider
Star Strider 2022년 7월 28일
The first element of the output of the fft function is the constant or DC offsets (mean values) of the original time domain vector. As a general rule, the second half of the original vector is the flipped complex conjugate of the first half of the vector. For a one-sided Fourier transform, the frequencies go from 0 Hz (DC) to the Nyquist frequency (half the sampling frequency). The sampling frequency (assuming a time vector with uniform increments, so a constant sampling frequency) is the inverse of the common sampling interval.
For a two-sided fft result (after using the fftshift function so that the centre frequency is 0 Hz) the frequency vector is:
Fv = linspace(-Fs/2, Fs/2-Fs/length(s), length(s)); % EVEN 'length(s)' (Asymmetric)
Fv = linspace(-Fs/2, Fs/2, length(s)); % ODD 'length(s)' (Symmetric)
This results in a two-sided Fourier transform with the ‘negative’ frequencies to the left of centre and the positive frequencies to the right of centre.
I generally zero-pad the fft argument using:
NFFT = 2^nextpow2(L);
FTs = fft(s, NFFT)/L;
where ‘L’ is the length of the associated time vector (since the signal can be either a vector or a column-oriented matrix where each column is a separate signal) and ‘s’ is the signal (vector or matrix). This improves the efficiency of the fft calculation, and also makes the subsequent analysis a bit easier.
.
  댓글 수: 1
Paul
Paul 2022년 7월 28일
Hi Star,
For an odd length sequence I believe that Fv is
Fv = linspace(-F2/2, Fs/2, length(s)) * (length(s) - 1)/length(s)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by