Page 80 - Applied Numerical Methods Using MATLAB
P. 80
PROBLEMS 69
(a) Similarly to the MATLAB routine “CtFT1(x,Dt,w)” computing the
CtFT (P1.26.1a) of x(t) over [-Dt,Dt ]for w, make a MATLAB rou-
tine “ICtFT1(X,Bw,t)” computing the ICtFT (P1.26.1b) of X(w) over
[-Bw, Bw]for t. You can choose whatever integral routine including
‘trpzds_par()’ (Problem 1.24) and ‘quad()’, considering the running
time.
(b) The following program ‘nm1p26’ finds the CtFT of a rectangular pulse
(with duration [−1,1]) defined by ‘rDt()’for ω = [−6π, +6π]and the
ICtFT of a sinc spectrum (with bandwidth 2π)defined by‘sincBw()’
for t = [−5, +5]. After having saved the routines into M-files with the
appropriate names, run the program to see the rectangular pulse, its
CtFT spectrum, a sinc spectrum, and its ICtFT. If it doesen’t work,
modify/supplement the routines so that you can rerun it to see the
signals and their spectra.
function Xw = CtFT1(x,Dt,w)
x_ejkwt = inline([x ’(t).*exp(-j*w*t)’],’t’,’w’);
Xw = trpzds_par(x_ejkwt,-Dt,Dt,1000,w);
%Xw = quad(x_ejkwt,-Dt,Dt,[],0,w);
function xt = ICtFT1(X,Bw,t)
function x = rDt(t)
x = (-D/2 <=t&t<= D/2);
function X = sincBw(w)
X = 2*pi/B*sinc(w/B);
%nm1p26: CtFT and ICtFT
clear, clf
global B D
%CtFT of a Rectangular Pulse Function
t = [-50:50]/10; %time vector
w = [-60:60]/10*pi; %frequency vector
D = 1; %Duration of a rectangular pulse rD(t)
for k = 1:length(w), Xw(k) = CtFT1(’rDt’,D*5,w(k)); end
subplot(221), plot(t,rDt(t))
subplot(222), plot(w,abs(Xw))
%ICtFT of a Sinc Spectrum
B = 2*pi; %Bandwidth of a sinc spectrum sncB(w)
for n = 1:length(t), xt(n) = ICtFT1(’sincBw’,B*5,t(n));
end
subplot(223), plot(t,real(xt))
subplot(224), plot(w,sincBw(w))
1:45 am, 6/4/05