PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

394 Practical MATLAB® Applications for Engineers


syms coesquare expon t ;
for k =1:5
expon = exp(-j*k*w0*t);
coesquare = .5*int(expon,-.5,.5);
Fn = .5*sin(k.*pi/2)./((k.*pi/2)+eps);
fn(k) = vpa(Fn);
f(k) = vpa(coesquare);
end
disp(‘***********************************************************’);
disp(‘Coefficients Fn of the exponential Fourier Series’);
disp(‘Harmonics Sym. Coeff. ‘);
disp(‘***********************************************************’);
results1 = [nn’ f’];
disp(results1)
disp(‘***********************************************************’);
disp(‘Harmonics Num. Coeff. ‘);
disp(‘***********************************************************’);
results2 = [nn’ fn’];
disp(results2)
disp(‘***********************************************************’);

The script fi le Fourier_coeff is executed and the results are as follows:

>> Fourier _ coeff
************************************************************************
Coefficients Fn of the exponential Fourier Series
Harmonics Sym. Coeff.
************************************************************************
[1, .31830988618379067153776752674503]
[2, 0]
[3, -.10610329539459689051258917558168]
[4, 0]
[5, .63661977236758134307553505349006e-1]
************************************************************************

Harmonics Num. Coeff.
************************************************************************
[1, .31830988618379063570529297066969]
[2, .19490859162596877471531966954150e-16]
[3, -.10610329539459689707214806730917]
[4, -.19490859162596877471531966954150e-16]
[5, .63661977236758135467731278822612e-1]

Note that the symbolic results fully agree with the numerical results. Also note that the
magnitude of the error is of the order 10−^16.

Example 4.6

Create the script fi le square_time_frq that explores the effects in the frequency domain of
changing the τ (tau) of the rectangular periodic wave function shown in Figure 4.44 in
the time domain, by plotting their respective spectrums, for the following values of τ =
1, 0.5, 0.25, and 0.125. Discuss the results obtained.
Free download pdf