FFT / IFFT question .

9 views (last 30 days)
Marcelo
Marcelo on 5 Dec 2011
I have a 4000 points time history rectangular pulse described as
t=linspace(0,0.4,4000);
for i=1:4000 if t(i)>=0&t(i)<=0.01 r(i)=1e5; else r(i)=0; end end
in the frequency domain i have :
y=r; L=length(y); Fs=L/0.4; NFFT = L; % Next power of 2 from length of y Y = fft(y,NFFT); f = Fs/2*linspace(0,1,NFFT/2);
The issue is :
If i use ifft(Y) i got the original time history (obviously) - no problem
but if i take half of the frequency domain vector and use ifft with the symmetric argument i got messed up time hystory . WHY ????
J=Y(1:NFFT/2+1); TD=ifft(J, 'symmetric');
TD is not the original time domain pulse . What am i missing here ?

Accepted Answer

Wayne King
Wayne King on 5 Dec 2011
Hi Marcelo, Even if you use 'symmetric' option, you still have to provide the entire frequency vector input. 'symmetric' just takes care of the rounding errors that can yield nonzero imaginary parts in the inverse Fourier transform of a conjugate symmetric Fourier representation.
You should input Y and not J. By inputtting
J = Y(1:/NFFT/2+1), you are giving ifft() an input vector that is not conjugate symmetric.
  2 Comments
Wayne King
Wayne King on 5 Dec 2011
Hi Marcelo, yes, but be careful with 0 and the Nyquist, they only occur once, so you don't want to repeat DC twice for example.

Sign in to comment.

More Answers (1)

Knut
Knut on 5 Dec 2011
Actually:
>> ifft([1 2 3 2 1], 'symmetric')
ans =
2.2000 -0.5236 -0.0764 -0.0764 -0.5236
>> ifft([1 2 3 NaN inf], 'symmetric')
ans =
2.2000 -0.5236 -0.0764 -0.0764 -0.5236
  2 Comments
Knut
Knut on 5 Dec 2011
Ah, I made the same error myself once. The "logical" way for the symmetric option to work would be that you only supplied the non-redundant vector, and I think that is how the underlying FFTW library works anyways. But in MATLAB it seems that we have to make a dummy vector 2x its needed length, before it gets internally stripped (?) down to 1x prior to calling FFTW.
I was hoping to speedup an application by doing minimal preprocessing before the call to IFFT, when only the non-redundantcoefficients were available to me.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!