# fftshift in MATLAB with even number of data points in double sided spectrum

I have a question with reference to this Table. 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.

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.
• 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. Jun 4, 2019 at 20:22
• 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. Jun 4, 2019 at 22:15
• 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. Jun 5, 2019 at 0:21