PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Fourier and Laplace 395


ANALYTICAL Solution

The coeffi cients of the exponential FS for f(t) are given by

F
T

n
n n




sin( / )
(/)

2
2

where T = 2 and

wn 0
2
2

 0

 for 

MATLAB Solution
% Script file: square _ time _ frq
echo off;
n =-10*pi:pi:10*pi;
tau1 =1;T=2;Tx1=tau1/T;
Fn1 = Tx1*sin(n*pi*Tx1)./(n*pi*Tx1+eps);
Fn1(11)=Tx1;
subplot(2,2,1);stem(n,Fn1);
title(‘ spectrum of square wave with tau=1’);axis([-30 30 -.6 .6]);
ylabel(‘Amplitude’); xlabel(‘w= n*wo (rad per sec)’);
tau2=0.5;T=2;Tx2=tau2/T;
Fn2=Tx2*sin(n*pi*Tx2)./(n*pi*Tx2+eps);
Fn2(11)=Tx2;
subplot(2,2,2);stem(n,Fn2);axis([-30 30 -.3 .3]);
title(‘ spectrum of square wave with tau=0.5’);
ylabel(‘Amplitude’); xlabel(‘w= n*wo (rad per sec)’);
tau3 = 0.25;T=2;Tx3=tau3/T; Fn3=Tx3*sin(n*pi*Tx3)./(n*pi*Tx3+eps);
Fn3(11) = Tx3;
subplot(2,2,3);stem(n,Fn3);axis([-30 30 -.15 .15]);
title(‘ spectrum of square wave with tau=0.25’);
xlabel(‘w= n*wo (rad per sec)’);ylabel(‘Amplitude’);
tau4 = 0.125;T = 2;Tx4 = tau4/T; Fn4 =Tx4*sin(n*pi*Tx4)./(n*pi*Tx4+eps);
Fn4(11) = Tx4;
subplot(2,2,4);stem(n,Fn4);axis([-30 30 -.1 .1]);
title(‘ spectrum of square wave with tau=0.125’);
xlabel(‘w= n*wo (rad per sec)’);ylabel(‘Amplitude’);

− 1 1

0.5

f(t)

t

1.0

T

−τ/2 0 −τ/2

FIGURE 4.44
Plots of f(t) of Example 4.6.
Free download pdf