|
I have two equations, one in the frequency domain (gf) and the other one in the time domain (gt). I used ifft to reconstruct the original function in the time domain (gt2). However, I couldn’t get back the original one. I was thinking there might a scaling issue. So, I applied followings: gt2.*N, gt2./N, gt2.*df, … none of them worked! this is my code:
% Time and frequency range
T=1000;
df=1/T;
N=60000;
f=eps:df:(N-1)*df; % Frequency range
t=T/2*linspace(eps,1,N);
w=2*pi.*f; % Angular frequency
%Function in the frequency domain
alph=(1+i).*sqrt(w/2);
gf=((1./(2*alph))).* exp(-alph.*2);
%Function in the time domain
gt = exp(-1./t)./(4*pi*t).^(1/2);
% Inverse Fourier transform
gt2=ifft(gf,N);
figure(1)
plot(t,real(gt))
figure(2)
plot(t,real(gt2))
I also changed my time and frequency range to include both positives and negatives (to see if that make a change) as the following. (A small value of eps was also added to each t or f in the equations to avoid NaN in zero frequency and time). I also applied ifftshift and switched positive and negative time components
gt22= ifft(ifftshift(gf)), gt2 = [gt22((round(N/2)+1):end) gt22(1:round(N/2))];
but it gave me a weird shape!
%New time and frequency range
df = 0.01;
fmax=10;
f = -fmax:df:fmax;
dt=1/(2*fmax);tmax=round((1/df)/2);
t = -tmax:dt:tmax;
N = length(f);
I also saw a similar post on this problem but it didn't help me . I would appreciate your help and suggestion.
Thank you
sharmin
|