PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Fourier and Laplace 381


Observe that at the discontinuity points or corners (at t = 0, 1, 2, 3...), an over-
shoot is clearly present. The overshoot is about 9%, even if the number of terms of the
approximation is increased to infi nity. This overshoot was fi rst observed by Josiah
Willard Gibbs (1839–1903), and is referred to as the Gibbs phenomenon, discussed and
presented, in this chapter background.
Observe also that the amplitudes of the different harmonics decrease as the
frequencies increase.

Example 4.2

Let the FS expansion for a periodic sawtooth wave be given by

ft
n

nw t
n

() sin( )


 11
1

6
∑^0

with period T = 2 s, and a fundamental frequency given by w 0 = 2 π/T = π.
Create the script fi lesawtooth_fourier that returns the following plots over the range
0 ≤ t ≤ 4:

a. The fi rst six nonzero Fourier components of f(t) versus t (for n = 1, 2, 3, 4, 5, 6) on
separate plots
b. The components of part a on one plot
c. Successive partial sums of the FS expansion on separate plots
d. Successive partial approximation sums of the FS expansion on the same plot
e. The [error(t)] versus t, for each of the FS approximations (sums) of part c

MATLAB Solution
% Script file: sawtooth _ fourier
% Harmonic Analysis for a sawtooth wave by a Fourier Series
% approximation, with fundamental frequency wo = pi
echo off;
T = 2;
w0 = 2*pi/T;
t = 0:.01:2*T;
%Harmonics are created below
Harmonic _ 1 = -1/pi*sin(w0.*t);
Harmonic _ 2 = -1/(2*pi)*sin(2*w0.*t);
Harmonic _ 3 = -1/(3*pi)*sin(3*w0.*t);
Harmonic _ 4 = -1/(4*pi)*sin(4*w0.*t);
Harmonic _ 5 = -1/(5*pi)*sin(5*w0.*t);
Harmonic _ 6 = -1/(6*pi)*sin(6*w0.*t);
figure(1); % Figure 4.33; part(a)
subplot(3,2,1);
plot(t,Harmonic _ 1);
title(‘fundamental freq. wo=\pi’);
ylabel(‘Amplitude’);
subplot(3,2,2);
plot (t,Harmonic _ 2);
title (‘2d. harmonic, freq.w=2\pi’);
ylabel (‘Amplitude’);
subplot (3,2,3);
plot (t,Harmonic _ 3);
Free download pdf