1

I have a question with reference to this Table. enter image description here

With even N, the frequency axis extremes should be $\pm$Fs/2, where Fs is the sampling frequency. However in the array we have only one value corresponding to the Nyquist frequency. Following the notation of the table in the first column, N=10, we have

[$c_{0}$ $c_{1}$ $c_{2}$ $c_{3}$ $c_{4}$ $c_{-5}$ $c_{-4}$ $c_{-3}$ $c_{-2}$ $c_{-1}$]

which after fftshift should become

[$c_{-5}$ $c_{-4}$ $c_{-3}$ $c_{-2}$ $c_{-1}$ $c_{0}$ $c_{1}$ $c_{2}$ $c_{3}$ $c_{4}$ ]

The $c_{-5}$ value corresponds to the Nyquist frequency. So how is our double sided frequency spectrum symmetric when N is even? For real valued function it will be zero, but is there a reason that MATLAB calculates the negative frequency first as shown in the Table?

Example: A_even=[ 0 0 0 1 1 1 1 0 0 0],

N=10

B=fft(A_even)'

C=fftshift(B)

Then C is equal to

$$\begin{matrix} 0.0000 + 0.0000i\\ -0.3090 - 0.9511i\\ 0.4271 + 0.5878i\\ 0.8090 + 0.5878i\\ -2.9271 - 0.9511i\\ 4.0000 + 0.0000i\\ -2.9271 + 0.9511i\\ 0.8090 - 0.5878i\\ 0.4271 - 0.5878i\\ -0.3090 + 0.9511i\\ \end{matrix}$$

This implies $c_{-5}$ = 0.0000 + 0.0000i and $c_{0}$= 4.0000+0000i Thanks.

AChem
  • 569
  • 4
  • 19

1 Answers1

4

If the size $N$ of the DFT is even, only one "extremal" point (after fftshift) is Nyquist. If $N$ is even, you cannot have an arbitary $c_{-5}$ and $c_5$. They must add to be whatever your $c_{-5}$ term is.

If the input to the DFT is purely real and if $N$ is even, consider the Nyquist point, at $c_{N/2}$ to be split in half. One half is the negative-frequency component and the other half is the positive-frequency component. Since the negative and positive frequency components must be complex conjugates of each other, and since $c_{-N/2}=c_{N/2}$ after splitting, that means that $c_{N/2}$ must be purely real just as $c_0$ must also be real.

robert bristow-johnson
  • 20,661
  • 4
  • 38
  • 76
  • Thanks. In the case of N (even) the double sided spectrum cannot be symmetric. $c_{-5}$ corresponds to the -Fs/2 and we do not have $c_{5}$ so there is no corresponding Fs/2 entry on the positive side. Is this correct? – AChem Jun 04 '19 at 03:30
  • 1
    Yes, that is correct about the DFT after you apply fftshift(). but in reality, that $c_{-5}$ is really split into two. half at the negative frequency and half at the positive frequency. this is not an issue for the case when $N$ is odd. – robert bristow-johnson Jun 04 '19 at 20:22
  • 1
    Try an input of [ 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1] and you will see some energy in the Nyquist component. – robert bristow-johnson Jun 04 '19 at 20:25
  • Right, when N is odd, all frequencies are below Nyquist. Will try this suggested series, but I am curious when you mention "that $c_{−5}$ is really split into two. half at the negative frequency and half at the positive frequency." What does that mean? $c_{−5}$ would be a unique complex number (zero imaginary part, right)? – AChem Jun 04 '19 at 21:46
  • 1
    The reason I said "that $c_{−5}$ is really split into two. half at the negative frequency and half at the positive frequency" is in response to what you said: "With even N, the frequency axis extremes should be ±Fs/2." When $N$ is even and the input is real, your $c_{−N/2}$ is actually the sum of the actual $c_{N/2}$ and $c_{−N/2}$. But $c_{N/2}$ is not returned by the DFT. – robert bristow-johnson Jun 04 '19 at 22:15
  • Interesting. Is it documented somewhere? Never saw this explained in MATLAB. In a rigorous sense, then one should not be including the -Fs/2 as well because $c_{-5}$ does not reflect the true value. In case, it is zero, then it does not matter. The fftshift output of your suggested series is [-8 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0]. Here N= 16, the -8 corresponds to the $c_{-8}$ at the negative Nyquist frequency. So is the true value of $c_{-8}$ is -4 and $c_{+8}$ is -4 or we cannot determine it? – AChem Jun 04 '19 at 22:42
  • 1
    This is more fundamentally about the Discrete-Fourier Transform than about MATLAB. All MATLAB does is the DFT in the traditional sense, but fucks up the indices with an offset of 1. $X(1)$ is the DC value and that is friggin' inexcusable. This thing about the Nyquist bin at $X[\tfrac{N}{2}]$ is really about how the DFT is connected to the true double-sided spectrum for a real input $x[n]$.

    And, yes, you got that right. you split $c_{-8}$ into two equal parts and the other half goes to $c_{+8}$ if you're considering these $c_k$ to be Fourier series coefficients.

    – robert bristow-johnson Jun 05 '19 at 00:21
  • 1
  • Yes, this idiosyncrasy of MATLAB with bin number is really annoying for those who are not hardcore programming. We have to deal with k =0,1,2,...N-1, then there is a bin number which starts from 1. I will be using (-(N/2):(N/2)-1 ) * Fs/N = as the scale for even N and a double sided spectrum. For a single sided one (0: (N/2)-1)*Fs/N. Hopefully this is correct. – AChem Jun 05 '19 at 00:51