FFT / IFFT question .
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 ?
0 comentarios
Respuesta aceptada
Wayne King
el 5 de Dic. de 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 comentarios
Wayne King
el 5 de Dic. de 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.
Más respuestas (1)
Knut
el 5 de Dic. de 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 comentarios
Wayne King
el 5 de Dic. de 2011
Hi Knut, that is correct, but that is not what the OP was doing. He was trying to do this.
rng default;
x = randn(8,1);
xdft = fft(x);
% Now truncate the DFT to only include DC up to and including the Nyquist
ifft(xdft(1:5),'symmetric');
That does not work. The OP was attempting to just provide ifft() from DC to the Nyquist.
Knut
el 5 de Dic. de 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.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!