Using the MATLAB 'symmetric' flag to compute the IFFT of a complex-valued, length-N (with N even), transfer function, the imaginary part of the complex value at the index ((N/2)+1) corresponding to the Nyquist frequency appears to be ignored. Why is this done instead of taking the magnitude of the complex value at the Nyquist frequency? How important are the values at the Nyquist frequency and DC for audio applications?


If you have an exactly conjugate-symmetric frequency domain vector, the values at DC and at Nyquist must be real-valued. The 'symmetric' flag of Matlab's ifft command makes sure that the result of the inverse FFT is real-valued, implying that the values at DC and Nyquist must also be real-valued.

Let $X[k]$ be the length $N$ DFT of a real-valued sequence $x[n]$:

$$X[k]=\sum_{n=0}^{N-1}x[k]e^{-j2\pi nk/N}\tag{1}$$

The value at DC is


which is clearly real-valued if $x[k]$ is real-valued. Similarly, assuming that $N$ is even, the value at Nyquist is

$$X[N/2]=\sum_{n=0}^{N-1}x[k]e^{-j\pi n}=\sum_{n=0}^{N-1}x[k](-1)^n\tag{3}$$

which is also real-valued for real-valued $x[n]$.

Conjugate symmetry means


which for $k=N/2$ (i.e., at Nyquist) gives


Of course, $(5)$ just shows in another way that the bin at Nyquist is real-valued for real-valued $x[k]$.

  • $\begingroup$ To be more specific, I am computing the frequency-domain spectrum up to the Nyquist frequency numerically based on an analytical formula (in particular, one that is based on the frequency-domain solution to scattering of an incident wave off a rigid sphere). The value at DC happens to be real, but that at the Nyquist frequency for the sampling rate I choose happens to be complex-valued. I want the corresponding IR to be real. If I use the symmetric flag in MATLAB to get the IR, it drops the imaginary part. Why is that done instead of keeping the magnitude? $\endgroup$ – Rahul Jul 29 '19 at 16:16
  • 2
    $\begingroup$ @Rahul: Because it is assumed that the value at Nyquist must be real (for real time-domain data), so any imaginary part must be a numerical error, that's why it's dropped. $\endgroup$ – Matt L. Jul 29 '19 at 16:17
  • 1
    $\begingroup$ Computing the magnitude would mean to take the erroneous imaginary part into account. $\endgroup$ – Matt L. Jul 29 '19 at 16:18
  • $\begingroup$ I follow you. But in my case, the complex value at the Nyquist freq. is exactly correct (since it is computed from an analytical expression). The problem is that the frequency-domain solution I use to compute the spectrum should, in theory, correspond to a continuous-time signal (i.e., there is no Nyquist frequency). For practical use, I set a sampling rate and this defines a Nyquist frequency at which I must force the spectrum value to be real. Do I always have to drop the imaginary part to do so (as MATLAB assumes) or can I set it to be the magnitude? $\endgroup$ – Rahul Jul 29 '19 at 16:32
  • 1
    $\begingroup$ @Rahul: If it is the magnitude that must be approximated, then you can indeed redefine the value at Nyquist by its magnitude. This is different from the usual case where you have inaccurate values due to numerical errors. $\endgroup$ – Matt L. Jul 29 '19 at 17:26

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.