필터 지우기
필터 지우기

FFT / IFFT question .

조회 수: 2 (최근 30일)
Marcelo
Marcelo 2011년 12월 5일
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 ?

채택된 답변

Wayne King
Wayne King 2011년 12월 5일
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
Marcelo
Marcelo 2011년 12월 5일
Thanks for your answer Wayne .
I didn`t realize that . What am i supposed to do if i have only half of the spectrum ? add fliplr(conj(Y)) to the original frequency vector before use ifft with symmetric argument ?
Wayne King
Wayne King 2011년 12월 5일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Knut
Knut 2011년 12월 5일
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
Wayne King
Wayne King 2011년 12월 5일
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
Knut 2011년 12월 5일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by