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

38 visualizaciones (últimos 30 días)
Ray Lee
Ray Lee el 10 de Jul. de 2014
Comentada: CHAN CHEN HUA el 7 de Oct. de 2021
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?

Respuesta aceptada

Honglei Chen
Honglei Chen el 10 de Jul. de 2014
Editada: Honglei Chen el 10 de Jul. de 2014
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 comentarios
Ray Lee
Ray Lee el 10 de Jul. de 2014
the output of fft is unique, but in the two formulae, the f axis is shifted by one point.
Honglei Chen
Honglei Chen el 10 de Jul. de 2014
Editada: Honglei Chen el 10 de Jul. de 2014
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

Iniciar sesión para comentar.

Más respuestas (1)

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

Iniciar sesión para comentar.

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by