1
$\begingroup$

I am using fft to plot the signal spectrum (convert real and imaginary components to amplitude values). If my signal is of odd length, I take $fft[0]$ as DC and use $fft[1;(N-1)/2)]$ values to get the amplitudes of the harmonics (from 1 Hz to (N-1)/2 Hz). But if my signal is of even length, the $fft$ element with index $fft[N/2]$ represents Nyquist frequency. Is it correct to use this frequency when plotting the amplitudes spectrum? Or in this case I should only consider elements in the range $fft[1; N/2-1]$ and DC at $fft[0]$?

$\endgroup$
3
  • 1
    $\begingroup$ It depends on what you are using the results for. As demonstrated in this link: dsp.stackexchange.com/questions/82273/… the Nyquist bin when shared (for even length sequences) can be split (in complex conjugate halves) between the positive and negative spectrum in situations where we need a components at each location, since that spectral location is the same. $\endgroup$ Commented Feb 7, 2023 at 17:32
  • 2
    $\begingroup$ What @DanBoschen said, except that in a lot of circumstances, if you have bins with significant energy in your FFT all the way up to the Nyquist frequency, then that's a strong indication that your real signal was aliased, and those frequency bins aren't valid anyway. $\endgroup$
    – TimWescott
    Commented Feb 8, 2023 at 15:43
  • 1
    $\begingroup$ Yes a most excellent point. What @TimWescott said, for all cases with real signals $\endgroup$ Commented Feb 8, 2023 at 17:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.