2
$\begingroup$

I've been working with even length audio for a while, so I've had no problem finding the Nyquist frequency in the FFT spectrum, as it's shape is:

$$(\text{dc_component}, f_1, f_2, ..., f_{N/2-1}, f_\text{NYQUIS}, -f_{N/2-1}, -f_{N/2-1}, ..., -f_1)$$

However, an odd number of elements doesn't fit this. What's the layout for odd FFT spectrums?

$\endgroup$
2
  • $\begingroup$ Continuing here because of chat limitation. It's (N-1)/2 not N/2-1 since N is odd. $X[k]$ is more conventional than $f_k$, using $i$ is a bad convention since $i$ (or $j$ for Engineers) is the symbol for $\sqrt{-1}$. $n$ is the usual iterator in the signal domain and $k$ for bins. Matlab throws things off by using 1 based indexing as 0 based is natural for the DFT. In my articles I use $Z_k$. Subscripting is mathematical notation for sequences. Using brackets is an alternative notation conventionally used in DSP. Using parentheses implies a continuous function. $\endgroup$ – Cedron Dawg Jul 12 '20 at 13:16
  • $\begingroup$ You're welcome. You shouldn't go any farther until you get a grip on complex numbers. One based indexing makes sense in traditional matrix math as that is how it is traditionally denoted. Original BASICs were also one based in arrays. Python is a dialect of BASIC (IMO) and a very good choice. $\endgroup$ – Cedron Dawg Jul 12 '20 at 13:27
0
$\begingroup$

You clearly haven't digested the information from the other answers I gave you. With an odd number of points, the Nyquist frequency lies cleanly between two bins and does not occur at a bin.

For conceptual purposes, an odd number of points let you set zero at the center flanked by the same number of points on each side. Likewise, the DFT can be centered at DC flanked by the same number of bins on each side, positive one way, negative the other.

Zero padding either domain means zero padding at the extremes.

More reading, more math, more popcorn: Using fourier coefficients to reconstruct data in matlab

$\endgroup$
8
  • $\begingroup$ For conceptual purposes, an odd number of points let you set zero at the center flanked by the same number of points on each side. Likewise, the DFT can be centered at DC flanked by the same number of bins on each side, positive one way, negative the other. what about the nyquis bin? do you delete it? For my analysis I'm applying a Hilbert transform, which flattens the negative frequencies (by zeroing the top half of the spectrum. If the nyquis frequency is split between 2 bins, I have no idea how you'd do this transform. $\endgroup$ – Tobi Akinyemi Jul 12 '20 at 12:26
  • $\begingroup$ I think the easiest solution is to remove one sample to even the signal out (or pad 1 zero to the end) $\endgroup$ – Tobi Akinyemi Jul 12 '20 at 12:26
  • $\begingroup$ Honestly, I don't understand all of that complex math/notation, which is why it might seem like I disregarded your last answer to my question. $\endgroup$ – Tobi Akinyemi Jul 12 '20 at 12:27
  • $\begingroup$ Absolutely a prerequisite. Start here: dsprelated.com/showarticle/754.php Answer to first comment: There is no Nyquist bin. A bin index $k$ (off by one in Matlab) corresponds to the number of cycles in the frame. The frequency units of a DFT are cycles per frame, with bin values representing tones of whole frequencies. $\endgroup$ – Cedron Dawg Jul 12 '20 at 12:33
  • $\begingroup$ So the layout is $(\text{dc_component}, f_1, f_2, ..., f_{N/2-1}, -f_{N/2-1}, -f_{N/2-1}, ..., -f_1)$? $\endgroup$ – Tobi Akinyemi Jul 12 '20 at 12:36
0
$\begingroup$

Lets assume the sampling frequency is 4 and the FFT size is 8. The FFT frequency vector is then $$[0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5]$$ subtracting $f_s=8$ from the frequencies greater than $f_s/2$ gives the following: $$[0, 0.5, 1, 1.5, 2, -1.5, -1, -0.5]$$

We can do the exact same thing for an odd length. To keep the math simple, the sampling frequency is 3.5 and the FFT size is 7. The frequencies of the FFT are then: $$[0, 0.5, 1, 1.5, 2, 2.5, 3$$ subtracting $f_s=3.5$ from the frequencies greater than $f_s/2$ gives the following: $$[0, 0.5, 1, 1.5, -1.5, -1, -0.5]$$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.