%Example 8-23: Using DFT to compute CTFT.
%2-sided exponential function:
clear;tmax=6;fmax=8;
T=2*tmax;B=2*fmax;
t=[-tmax:1/B:tmax-1/B];
f=[-fmax:1/T:fmax-1/T];
X=exp(-abs(t));
fX=2./(4*pi*pi*f.*f+1);
FX=fftshift(abs(fft(X)))/B;
figure,subplot(211),plot(f,fX,'o',f,FX,'+r')
%Gaussian function:
tmax=4;fmax=0.625;
T=2*tmax;B=2*fmax;
t=[-tmax:1/B:tmax-1/B];
f=[-fmax:1/T:fmax-1/T];
Y=exp(-t.*t/2)/sqrt(2*pi);
fY=exp(-2*pi*pi*f.*f);
FY=fftshift(abs(fft(Y)))/B;
subplot(212),plot(f,fY,'o',f,FY,'+r')