PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Fourier and Laplace 409


xw =2*pi*sin(w*pi)./(w*pi);
% FT of x(t) from Table 4.1,transf.#3
% H(w) = 6/(w^2+9);
% FT of h(t) from Table 4.1,transf.#13
a = [6];
b = [1 0 9];
Hw = freqs(a,b,w);
magxw = abs(xw);
magHw = abs(Hw);
yw = magxw.*magHw;
figure(1)
subplot(3,1,1);plot(w,magxw);
ylabel(‘Magnitude’);axis([-6 6 0 8]);
title(‘ X(w) vs.w’);xlabel(‘frequency w(rad/sec)’);
subplot(3,1,2);plot(w,magHw);axis([-6 6 0 8]);
ylabel(‘Magnitude’);
title(‘ H(w) vs.w’);xlabel(‘frequency w(rad/sec)’);
magyw=magxw.*magHw;
subplot(3,1,3)
plot(w,magyw);axis([-6 6 0 5]);
ylabel(‘Magnitude’);
title(‘ Y(w) vs.w’);xlabel(‘frequency w(rad/sec)’);
figure(2)
plot(w,magHw);
title(‘ H(w) vs. w (showing impulses)’);
ylabel(‘Magnitude’);xlabel(‘fequency w (rad/sec)’)
magyw=magxw.*magHw;
%time domain analysis
figure(3)
t=-5:.1:5;
xt=[zeros(1,20) ones(1,61) zeros(1,20)];
ht=exp(-3.*abs(t));
hut=[zeros(1,50) ones(1,51)];htt=ht.*hut;
conxh=conv(xt,ht);
tt=-10:.1:10;
subplot(3,1,1)
plot(t,xt);axis([-5 5 0 1.5])
title(‘x(t) vs. t’);
ylabel(‘Amplitude’);xlabel(‘time (in sec)’)
subplot(3,1,2)
plot(t,ht);
title(‘h(t) vs. t’);
axis([-2 2 0 1.5])
ylabel(‘Amplitude’);xlabel(‘time (in sec)’);
subplot(3,1,3)
plot(tt,conxh);
title(‘y(t) vs. t’);
ylabel(‘Amplitude’);
xlabel(‘time (in sec)’)
% Symbolic evaluations
syms x;
FTx = fourier(sym(‘Heaviside(x-pi)’)-sym(‘Heaviside(x+pi)’));
Free download pdf