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$ Jan 2 '16 at 4:21
  • $\begingroup$ have you tried fftshift() yet? $\endgroup$ Jan 2 '16 at 17:19
  • 1
    $\begingroup$ what does it do to your time-domain plot? $\endgroup$ Jan 3 '16 at 4:31
  • $\begingroup$ As I do ifft that should be the time-domain plot, right? $\endgroup$ Jan 3 '16 at 6:01
  • $\begingroup$ apply to this: NFFT=4301; AvIFFT = ifft(FFTavg.dat,NFFT); before this: plot(real(AvIFFT)) $\endgroup$ Jan 3 '16 at 6:02

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$ Jan 3 '16 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
    Jan 4 '16 at 14:19
  • $\begingroup$ Thanks for the advice. I will try to average the time series and compare. $\endgroup$ Jan 5 '16 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
    Jan 5 '16 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$ Jan 6 '16 at 6:04

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.