268 C H A P T E R 4: Frequency Analysis: The Fourier Series
FIGURE 4.12
Approximate Fourier seriesxN(t)of the pulse
trainx(t)(discontinuous) using the DC component
and 20 harmonics. The approximatexN(t)
displays the Gibb’s phenomenon around the
discontinuities.0 0.2 0.4 0.6 0.8− 1−0.500.51x(t),xN(t
)t(sec)%%%%%%%%%%%%%%%%%
% Example 4.9---Simulation of Gibb’s phenomenon
%%%%%%%%%%%%%%%%
clf; clear all
w0 = 2∗pi; DC = 0; N = 20; % parameters of periodic signal
% computation of Fourier series coefficients
for k = 1:N,
X(k) = sin(k∗pi/2)/(k∗pi/2);
end
X = [DC X]; % Fourier series coefficients
% computation of periodic signal
Ts = 0.001; t = 0:Ts:1−Ts;
L = length(t); x = [ones(1, L/4) zeros(1, L/2) ones(1, L/4)]; x = x−0.5;
% computation of approximate
xN = X(1)∗ones(1,length(t));
for k = 2:N,
xN = xN + 2∗X(k)∗cos(2∗pi∗(k−1).∗t); % approximate signal
plot(t, xN); axis([0 max(t) 1.1∗min(xN) 1.1∗max(xN)])
hold on; plot(t, x, ’r’)
ylabel(’x(t), xN(t)’); xlabel(’t (sec)’);grid
hold off
pause(0.1)
endWhen you execute the above script, it pauses to display the approximation for an increasing num-
ber of terms in the approximation. At each of these values ringing around the discontinuities the
Gibb’s phenomenon is displayed. n