What are the frequencies when N in fft(x,N) is odd?

조회 수: 39 (최근 30일)
Ray Lee
Ray Lee 2014년 7월 10일
댓글: CHAN CHEN HUA 2021년 10월 7일
I know when N is even, fft(x,N) corresponds to frequencies 0,df,...,N/2*df,-(N/2-2)*df,...,-df.
What about if N is odd?

채택된 답변

Honglei Chen
Honglei Chen 2014년 7월 10일
편집: Honglei Chen 2014년 7월 10일
In general, you can do it as
f = (0:N-1)*fs/N
If you want to map it to negative frequencies
if N is even
f(N/2+1:end) = f(N/2+1:end)-fs % sample -fs/2
or
f(N/2+2:end) = f(N/2+2:end)-fs % sample fs/2
if N is odd
f((N+1)/2+1:end) = f((N+1)/2+1:end)-fs
HTH
  댓글 수: 4
Ray Lee
Ray Lee 2014년 7월 10일
the output of fft is unique, but in the two formulae, the f axis is shifted by one point.
Honglei Chen
Honglei Chen 2014년 7월 10일
편집: Honglei Chen 2014년 7월 10일
That's not true. Only one point is changed, from fs/2 to -fs/2 and because the result is periodic, they are indeed the same so you can mark it either way

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

추가 답변 (1개)

Michael scheinfeild
Michael scheinfeild 2014년 7월 10일
if x is ampled at fs you can generate frequency vector use
freqvec=linspace(0,fs,N);
  댓글 수: 3
Honglei Chen
Honglei Chen 2014년 7월 10일
This is incorrect. linspace always sample the last one, which you don't want.
CHAN  CHEN HUA
CHAN CHEN HUA 2021년 10월 7일
@Honglei Chen Hi, can i know why last sample should not be taken into?

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

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by