If we have an even number of data points $N$, after DFT in MATLAB, the output has the order:

$$(\text{DC}, f_1, f_2, \ldots, f_{N/2-1}, f_\text{Nyq}, -f_{N/2-1}, -f_{N/2-2}, \ldots, -f_1)$$

For real signals, the first output corresponding to $k$=0, is real and so is the Nyquist frequency. After that numbers are complex conjugates.

If we are interested in a single sided spectrum, the Nyquist frequency is shown on the positive side.

However, when a double-sided frequency spectrum is plotted, many authors put the Nyquist frequency on the negative side.

Some software like OriginPro, follow the opposite. Is there a fundamentally correct way or is it just a convention i.e.,

$$ \text { If } N \text { is even, } \quad k\quad\text { takes: }-\frac{N}{2}, \ldots,-1,0,1, \ldots, \frac{N}{2}-1 $$

Alternatively, $$ \text { If } N \text { is even, } \quad k \text { takes: } -\frac{N}{2}-1, \ldots,-1,0,1, \ldots, \frac{N}{2}$$

where $k$ is the DFT index vector, which is used to construct the frequency axis as

$$\text {Frequency axis}=k/ N\Delta t$$

where $\Delta t$ is the sampling interval.

Many people say it is just a convention and both are correct. Thanks.

  • 1
    $\begingroup$ The last sentence in your question is the answer. $\endgroup$
    – Matt L.
    Commented Jan 10, 2021 at 9:00
  • $\begingroup$ MATLAB doesn't do $+f_{Nyq}$. $\endgroup$ Commented Jan 10, 2021 at 9:32

3 Answers 3


It's convention, they're equivalent:

$$ \exp{\left(j2 \pi \frac{N}{2}n/N \right)} = \exp{\left(j2\pi \frac{-N}{2}n/N\right)} \\ \Rightarrow e^{j\pi n} = e^{-j \pi n} \Rightarrow \cos(\pi n) = \cos(-\pi n)=(-1)^n,\ j\sin(\pi n) = j\sin(-\pi n) = 0 $$

MATLAB and Numpy go $[-N/2, ..., N/2-1]$, which is unfortunate for analytic representations (+ freqs only). Note also its value is doubled relative to other bins (but not manually; they correlate this way), so in a sense it's both a negative and positive frequency, so energy's preserved:

enter image description here

You can tell a library's preference by fftshift docs:

enter image description here

  • $\begingroup$ Thanks, but I am still wondering about the basis that the Nyquist value is doubled? $\endgroup$
    – ACR
    Commented Jan 10, 2021 at 16:26
  • $\begingroup$ @M.Farooq $\text{sum}([1, -1, ...]^2) = 2N$. Recall, $X$ at $k$ is multiply-summed by $\cos{(2\pi k n / N)}$ for the real part, which at $k=N/2$ is $[1, -1, ...]$. Intuitively, unlike for any other $k$, every point at $k=N/2$ is a peak, so squared-sum is higher. $\endgroup$ Commented Jan 10, 2021 at 16:32
  • $\begingroup$ Do you know of a book which specifically mentions this doubling issue? $\endgroup$
    – ACR
    Commented Jan 10, 2021 at 16:47
  • $\begingroup$ @M.Farooq It's more a benefit, as you sort of keep both + and - in one. Energy calculations are to be adjusted as here, idea similar to fft vs rfft. I'm not aware of texts discussing various implications of this; should be its own question depending what you seek. $\endgroup$ Commented Jan 10, 2021 at 17:17
  • $\begingroup$ Okay that is better because I have not seen this discussed, at least in the standard book like Bracewell. $\endgroup$
    – ACR
    Commented Jan 10, 2021 at 17:19

There is a contextual problem here with equivalence, and with what is stated as "convention" or preference. One can suggest a preference for displaying the FFT or DFT. i.e., "let's include the Nyquist frequency in the display, on the right half"... For example, if you have 256 time points, the FFT/DFT is also 256 points, but only the first 128 are positive frequency, starting with DC, and landing just short of Nyquist. You can argue that the Nyquist frequency doesn't even exist in the positive frequency space. But, the problem is fundamental. Answer 2 above mathematically shows what people often forget: The principle assumption/acceptance in applying the FFT/DFT is that the original time series is cyclic (which may not actually be physical). The 1st point follows the Nth point ad infinitum (which is why people consider return to zero, windowing, or padding to represent physical reality). So, the convention stated here is to display N/2+1 points (129) to include the Nyquist frequency amplitude (and interpret/display as positive instead of negative frequency).

But you have to be extremely careful when using half-side FFTs and trying to apply a filter or performing the inverse, which Answer 2 above does not convey. If you change the FFT/DFT for display purposes, you MUST reverse the change prior to operating on it, i.e. remove that (appended) Nyquist point.

Now, if you have an odd number of original points, then the Nyquist is unambiguously the central DFT point, and serves as positive and/or negative frequency. No adjustments are necessary. When you invert, you get back the original odd points so long as you haven't filtered it against the sign/phase convention employed. If instead you started with an even number of original points, then included the N/2+1st Nyquist point and left it in, then upon inverting, you would NOT recover the original data.

Too many people lose sight of the indexing or cyclic structure of the FFT being like that of a signed binary integer. Take our 256-point example, where frequency ranges from 0 to 127 (0x7F) and then immediately -128 (0x80) to -1 (0xFF). The purpose of this ordering structure is to be continuous around zero. -1 (0xFF) rolls around continuously to 0, 1, ... (dropping the 3rd carry column). The ordering is inherently discontinuous at the N/2+1st (129th) Nyquist point, and folks prefer instead to display it with the right half swapped with the left half, to preserve continuous frequency at 0. Just be aware that this flopping of halves is being done in the background, and keep the same convention when applying a filter.

The safest way of processing FFT data is to always retain the original (complete) FTT structure for calculation, and only fudge its presentation. No harm is made in limiting the displayed range to N/2 or N/2+1, so long as you realize that the frequency scale is always spaced at 1/N (true for odd DFTs as well). When considering only the magnitude or power, it is definitely useful. But it is all too easy to forget the artificial acrobatics when performing a complex (phasor) calculation.

My favorite reference on these nuances is The Fourier Transform & Its Applications, by Ron Bracewell, McGraw-Hill. (1st,2nd,3rd editions: 1978, 1986, 1999)


Assuming $x[n]$ is real, resulting in $X[k]$ being "Hermitian symmetric";

$$ X[N-k] = (X[k])^* $$

and if $N$ is even, then the value in the DFT bin $X[\tfrac{N}{2}]$ (which is a real quantity with zero imaginary part) should be split into two equal halves. One half should be placed at $k=-\tfrac{N}{2}$ and the other half placed at $k=+\tfrac{N}{2}$.

This previous answer deals with this.

  • $\begingroup$ I think we had discussed this before here. How can we have both -N/2 and +N/2 for an even output. I would really appreciate if you know of a reference which does this and explains the fundamental basis of splitting it. Most people take the Nyquist value to the negative side (in Matlab's fftshift). I have browsed plenty of books, but could not find this particular point addressed. $\endgroup$
    – ACR
    Commented Jan 10, 2021 at 5:15
  • $\begingroup$ if $x[n]$ is real, it must have both $X[-\frac{N}2]$ and $X[+\frac{N}2]$ because if $x[n]$ is real, then the spectrum must be Hermitian symmetric. $\endgroup$ Commented Jan 10, 2021 at 6:02
  • $\begingroup$ If N=6, the output is like $\left[c_{0}, c_{+1}, c_{+2}, c_{-3}, c_{-2}, c_{-1}\right]$ and after fftshift it is $\left[c_{-3}, c_{-2}, c_{-1}, c_{0}, c_{+1}, c_{+2}\right]$, where is X[+N/2] here? $\endgroup$
    – ACR
    Commented Jan 10, 2021 at 6:13
  • 2
    $\begingroup$ Only one Nyquist bin for even $N$; unequal number of positive and negative bins. $\endgroup$ Commented Jan 10, 2021 at 9:28

Your Answer

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

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