PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Fourier and Laplace 377


figure(1); % Figure 4.28, part(a)
subplot(2,2,1);
plot(t,Harmonic _ 1);
title(‘fundamental freq. wo=pi’);
ylabel(‘Amplitude’);
subplot(2,2,2);
plot(t,Harmonic _ 3);
title(‘3rd. harmonic, freq.w=3*wo’);
ylabel(‘Amplitude’);
subplot(2,2,3);
plot(t,Harmonic _ 5);
title(‘5th. harmonic, freq.w=5*wo’);
ylabel(‘Amplitude’);
xlabel(‘ time (in sec)’);
subplot(2,2,4);
plot(t,Harmonic _ 7);
title(‘7th. harmonic, freq.w=7*wo’);
ylabel(‘Amplitude’); axis([0 4 −0.15 0.15])
xlabel(' time (in sec)');

figure(2); % Figure 4.29, part (b)
plot(t,Harmonic _ 1,t,Harmonic _ 3,t,Harmonic _ 5,t,Harmonic _ 7);
title('Harmonic components of the square wave');
ylabel('Amplitude');
xlabel('time (sec) ');

figure(3); % Figure 4.30, part(c)
subplot(2,2,1)
plot(t,Harmonic _ 1);
title('fundamental frequency (square)');
ylabel('Amplitude');
subplot(2,2,2);
Har _ 13 = Harmonic _ 1+ Harmonic _ 3;
plot(t,Har _ 13);
title('fund.+ 3rd. harmonic ');
ylabel('Amplitude');
subplot(2,2,3);
Har _ 135 = Harmonic _ 1+ Harmonic _ 3+ Harmonic _ 5;
plot(t,Har _ 135);
title('fund.+3rd.+ 5th harmonic ');
ylabel('Amplitude');
xlabel('time (in sec)');
subplot(2,2,4);
Har _ 1357 = Harmonic _ 1+ Harmonic _ 3+Harmonic _ 5+Harmonic _ 7;
plot(t,Har _ 1357);
title('fund.+ 3rd.+ 5th.+ 7th. harmonic ');
ylabel('Amplitude');
xlabel('time (in sec)');

figure(4); % Figure 4.31, part (d)
plot(t,Harmonic _ 1,t,Har _ 135,t,Har _ 1357);
title('Plots of square wave approximations using harmonics ');
xlabel('time (in sec)');
ylabel('Amplitude');
Free download pdf