PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Fourier and Laplace 405


axis([-5 5 0 0.6])
subplot(2,2,2);plot(w,phase*180/pi)
xlabel(‘frequency w’);ylabel(‘Angle in degrees’)
title(‘Phase spectrum/Fourier’);
a = [1]; % F(s) = 1/(s+2)
b = [1 2];
H = freqs(a,b,w);
mag = abs(H);ang = angle(H);
degrees = ang*180/pi;
subplot(2,2,3);plot(w,mag)
xlabel(‘frequency s’);ylabel(‘Magnitude of F(s)’)
title(‘Magnitude spectrum/Laplace’);
axis([-5 5 0.1 0.6])
subplot(2,2,4);plot(w,degrees)
xlabel(‘frequency s’);ylabel(‘Angle in degrees’)
title(‘Phase spectrum/Laplace’);

figure(3)
% Fourier transform using the symbolic toolbox
syms v;
disp(‘********************************’)
disp(‘The sym Fourier transform ‘)
disp(‘of(exp(-2*t)*u(t)) is=’)
FT= fourier(exp(-2*v)*sym(‘Heaviside(v)’))
disp(‘********************************’)
% Laplace transform using symbolic toolbox
disp(‘********************************’)
disp(‘The sym Laplace transform ‘)
disp(‘of(exp(-2*t)*u(t)) is=’)
LT=laplace(exp(-2*v)*sym(‘Heaviside(v)’))
disp(‘********************************’)
subplot(2,1,1);
ezplot(abs(FT));
title(‘sym Fourier transf of(exp(-2*t)*u(t))’)
ylabel(‘Magnitude of F(w)’);xlabel(‘frequency w’);
subplot(2,1,2);
ezplot(abs(LT));
title(‘sym Laplace transf of(exp(-2*t)*u(t))’)
ylabel(‘Magnitude of F(s)’);
xlabel(‘frequency s’);axis([-4 0 0 45])

The script fi le Fourier_ Laplace is executed and the results are as follows (Figures 4.52
through 4.54):

>> Fourier _ Laplace

*****************************************
*********** R E S U L T S ************
*****************************************
The int(exp(-2*t)*u(t)) from t=0 to inf is =
1/2

ans =
.50000000000000000000000000000000
Free download pdf