Fourier and Laplace 397
Create the script fi le Fourier_ approx that returns the following:
- The plots of the approximation for f(t) using the fi rst 26, 11, and 4 terms of the
trigonometric FS, over the range − 3 ≤ t ≤ +3. - For each of the approximation plots of part 1, evaluate the values of f(t) at t = 0
and 0.1. - Plot the four-term trigonometric FS approximation over the range 1 ≤ t ≤ 2, with
and without the help of a Hamming window, and observe the effects of the window-
ing process.
MATLAB Solution
%Script file : Fourier _ approx
echo off ;
t =−3:0.1:3;
x25=0;
for n=1:1:25;
xn25=1/(pi*n)*sin(2*pi*n*t);
x25=x25+xn25; % sum of 25 terms
end;
ft26=0.5+x25; % add the DC
figure(1)
subplot(3,1,1);plot(t,ft26)
title('26 term approximation ')
ylabel('Amplitude')
x10=0;
for n=1:1:10;
xn10=1/(pi*n)*sin(2*pi*n*t);
x10=x10+xn10; % sum of 10 terms
end;
x3=0;
for n=1:1:3;
xn3 =1/(pi*n)*sin(2*pi*n*t);
x3 = x3+xn3; % sum of 3 terms
end;
ft4 = 0.5+x3; % add DC
ft11 = 0.5+x10;
subplot(3,1,2);plot(t,ft11);
ylabel('Amplitude');
title('11 term approximation ')
subplot(3,1,3);
plot(t,ft4);ylabel('Amplitude')
0
t (s)
f(t)
1
1
T=1
FIGURE 4.46
Plot of f(t) of Example 4.7.