I performed an FFT with some zero padding and would like to transform it back to time domain. When I plot the signal it looks wrong. Is it because of the padding used in the FFT? How can I make it right? here is my code for doing the IFFT:

AvIFFT = ifft(FFTavg.dat,NFFT);

And I get this plot: enter image description here

Any help would be greatly appreciated! Thank you!

ps: I have asked this question on matworks but no success as yet.


As suggested in the comment and answer below, I tried fftshift:

NFFT = 4301;
FFTshifted = fftshift(FFTavg.dat);
AvIFFT  = ifftshift(FFTshifted,NFFT);   

Here is the plot:

enter image description here

  • $\begingroup$ look up the MATLAB function fftshift(). $\endgroup$ Commented Jan 2, 2016 at 4:21
  • $\begingroup$ have you tried fftshift() yet? $\endgroup$ Commented Jan 2, 2016 at 17:19
  • 1
    $\begingroup$ what does it do to your time-domain plot? $\endgroup$ Commented Jan 3, 2016 at 4:31
  • $\begingroup$ As I do ifft that should be the time-domain plot, right? $\endgroup$ Commented Jan 3, 2016 at 6:01
  • $\begingroup$ apply to this: NFFT=4301; AvIFFT = ifft(FFTavg.dat,NFFT); before this: plot(real(AvIFFT)) $\endgroup$ Commented Jan 3, 2016 at 6:02

2 Answers 2


user3406207: I'm not sure what you're trying to do because I don't know the meaning of your words "wrong" and "right." But we can say, if you perform time-domain zero padding on an original unpadded $x1[n]$ input sequence you'll produce some longer-length $x2[n]$ sequence. The $X2[m]$ fft of your $x2[n]$ sequence will be an interpolated version of (more freq-domain samples than) the $X1[m]$ fft of your $x1[n]$ sequence. And, of course, the inverse fft of $X2[m]$ will be $x2[n]$ and the inverse FFT of $X1[m]$ will be $x1[n]$. I hope that helps. (By the way, you were smart to plot just the real part of your inverse fft.)


The plot is correct. You have to remember that with the DFT the time domain is also periodic, so the left side of the plot represents time $t=0$ and the far right side represents time $t<0$. If you use fftshift the plot will look as you'd expect except that the middle of your plot will reresent time $t=0$.

Saw the edits you made to your code - I think you be skipping the first fftshift. I always use fftshift - I can't recall the difference between fftshift and ifftshift. See example below. Actually I think there is an error in your new code - it should be ifft rather than ifftshift.

NFFT = 4301;
AvIFFT  = ifft(FFTavg.dat,NFFT);   
  • $\begingroup$ Thank you. I tried to use fftshift() above. As this fft is the result of an average, I cannot check with initial signal. Is it normal that it is very symmetric like this? Or did I make an error in the code? $\endgroup$ Commented Jan 3, 2016 at 4:12
  • $\begingroup$ Well, it depends on what your original time series is, so I can't say. You really need to show what the original time series is, even if it is averaged. You should look at the ifft of FFTavg.dat without any interpolation - your interpolated result should appear similar but interpolated i.e. a higher time sampling. $\endgroup$
    – David
    Commented Jan 4, 2016 at 14:19
  • $\begingroup$ Thanks for the advice. I will try to average the time series and compare. $\endgroup$ Commented Jan 5, 2016 at 3:37
  • $\begingroup$ @user3406207 For your FFTavg.dat are the complex valued FFTs averaged or is it their magnitudes or something else? $\endgroup$
    – David
    Commented Jan 5, 2016 at 16:06
  • $\begingroup$ This is how I averaged the ffts of my time series: Y(:,i) = fft(dat1(i),Padding); avg = sum(abs(Y),2)/size(Y,2); FFTavg.dat = avg; $\endgroup$ Commented Jan 6, 2016 at 6:04

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.