PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

398 Practical MATLAB® Applications for Engineers


xlabel('time (in sec)')
title('4 term approximation ')
minft26 = min(ft26); maxft26 = max(ft26);
minft11 = min(ft11); maxft11 = max(ft11);
minft4 = min(ft4);maxft4 = max(ft4)
A=[minft26 maxft26];
disp(‘******************************************’)
disp(' *********R E S U L T S ****************')
disp('***********************************************************');
disp ('The magnitude of f(t) using 26 terms at t = 0, and t = 0.1
are:');
disp (A);
B=[minft11 maxft11];C=[minft4 maxft4];
disp ('The magnitude of f(t) using 11 terms at t = 0, and t = 0.1
are:');
disp (B)
disp ('The magnitude of f(t) using 4 terms at t = 0 , and t = 0.1
are:');
disp (C);
disp('************************************************************');
win=hamming(21)
figure(2)
subplot(2,1,1); tt=1:.1:2;
Ft4=ft4(21:41); F4=ft4(31:41)
plot(tt,F4)
title('Four term approximation over one cycle');
ylabel('Amplitude');
subplot(2,1,2)
ft4 _ win = Ft4.*win';ttt =1:.1:2, f4 = ft4 _ win(11:21)
plot(ttt,f4)
title('Four term hamm. window approximation over one cycle');
ylabel('Amplitude');
xlabel('time (in sec)')
Back at the command window, the script fi le Fourier_ approx is executed and the results
are as follows:
>> Fourier _ approx
******************************************
*********R E S U L T S ******************
***********************************************************
The magnitude of f(t) using 26 terms at t=0 , and t=0.1 are:
0.0806 0.9194
The magnitude of f(t) using 11 terms at t=0 , and t=0.1 are:
0.1469 0.8531
The magnitude of f(t) using 4 terms at t=0 , and t=0.1 are:
0.0606 0.9394
*************************************************************
Observe that the approximation using four terms is better than the approximation using 26
or 11 terms evaluated at t = 0 and 0.1; but of course not over a larger range (Figure 4.47).
Figure 4.48 shows the fourier trigonometric series expansion improvement over one
cycle with and without windowing the partial sum. Observe that the windowing process
removes some ripples from the partial sum of the triangular waveform, and the result
is a smoother wave.
Free download pdf