I want to stress that this is not a coding problem, my problem is that i don't fully understand the mathematics surrounding the subject and that's why I believe I have a problem.

I was given an assignment to choose a song (I chose the song Stricken by disturbed), perform fast fourier transform on the song, this will shift us from time domain to frequency domain.

Now I was asked to remove the first $10000$ frequencies. if $f(t)$ describes the signal of the song, and $\hat f(u)$ describes the fourier transform of the signal, then define $\hat g(u)$ such that $g(u)=0$ for all $u \in [0,10000]$ and $\hat g(u)=\hat f(u)$ otherwise.

After I removed the first $10000$ frequencies, I was asked to do something else that the teacher kept hidden from us and wanted us to figure out ourselves what we need to do, then perform an inverse fourier transform on $\hat g(u)$ to get $g(t)$. If the hidden action was performed correctly, than $g(t)$ should be strictly real.

So the goal of this exercise is to find out what the hidden action is.

Here is what I think:

The problem with removing the first $10000$ frequencies is that the magnitude is no longer even.

We know for sure, that if $f(t)$ is strictly real, then $|\hat f(u)|$ is even. For example, this is a graph of the magnitude of the fourier transform as a function of frequency, of the song i sampled

magnitude of fourier transform as function of frequency

Now if I change the first $10000$ values of the fourier transform, the magnitude of transform as function of frequency looks like

enter image description here

You can clearly see that now the magnitude is not an even function. So there is no way that the inverse transform will be a real function.

However, if we now also remove the last $10000$ frequencies, the magnitude should be an even function.

And the graph shows that it is. However, when I calculate the inverse transform, it is not a real function. So something is wrong or missing.

Here is the code that I wrote:

enter image description here

As you can see, after invoking the inverse fourier transform, i get a function that is not real. Why? What am I missing?

  • $\begingroup$ Signal Processing S.E. exists. $\endgroup$
    – Git Gud
    Mar 13, 2015 at 18:40
  • $\begingroup$ Thank you Git. Posted the question there. $\endgroup$ Mar 13, 2015 at 18:44
  • $\begingroup$ Deleted the question from DSP.SE. Please do not cross-post. Ask the moderators to move your original question, if that is what they think is the right thing to do. Since your question has been answered here, it might as well stay here. $\endgroup$
    – Peter K.
    Mar 13, 2015 at 20:13

2 Answers 2


You are actually zeroing out the last $10001$ samples of the FT: length(490000:500000) = 100001. However, that's not the only problem. Remember that the first sample in the FFT is DC and that there is only one value for it. Thus, you want to zero out the last $9999$ samples of the FFT:

N = 500e3;
Nz = 10e3;
x = rand( N, 1 );
X = fft( x );
Xz = X;
Xz(1:Nz) = 0;
Xz(end-Nz+2:end) = 0;
xz = ifft( Xz );
whos xz
  Name           Size              Bytes  Class     Attributes

  xz        500000x1             4000000  double              

sum( imag( xz(:) ) )

ans =


The trick is only a complex conjugate spectrum will give back real values after doing inverse fft.

You need to arrange your frequency using fftshift in matlab, then you can see the maximum peak will be starting frequency. try to make zero on either side. it will give real values after ifft.

Note: make sure your signal length is a $2^n$, if not padded it zeros to make the length $2^n$.

Ex: if signal length is $1000$ make it $1024$ ($2^{10}$) by padding $24$ zeros at end.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .