PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

382 Practical MATLAB® Applications for Engineers


title (‘3rd. harmonic, freq.w =3\pi’);
ylabel (‘Amplitude’);
subplot (3,2,4);
plot (t,Harmonic _ 4);
title (‘4th. harmonic, freq. w = 4\pi’);
ylabel (‘Amplitude’);
subplot (3,2,5);
plot (t,Harmonic _ 5);
title(‘5th. Harmonic, freq. w =5\pi’);
ylabel(‘Amplitude’);
xlabel(‘time in sec.’)
subplot (3,2,6);
plot (t,Harmonic _ 6);
title (‘6th. Harmonic, freq. w = 6\pi’);
ylabel (‘Amplitude’);
xlabel (‘time in sec.’)

figure(2); % Figure 4.34, part (b)
plot(t,Harmonic _ 1,t,Harmonic _ 2,t,Harmonic _ 3,t,Harmonic _ 4);
hold on;
plot(t,Harmonic _ 5,t,Harmonic _ 6);
title(‘Harmonic components of a sawtooth wave’);
ylabel(‘Amplitude’);
xlabel(‘time (in sec)’);

figure(3); % Figure 4.35; part (c)
subplot(3,2,1)
plot(t,Harmonic _ 1);
title(‘fundamental components of the sawtooth’);
ylabel(‘Amplitude’);
subplot(3,2,2);
Har _ 12=Harmonic _ 1+Harmonic _ 2;
plot(t,Har _ 12);
title(‘Fund.+2nd.Harmonic of the sawtooth’);
ylabel(‘Amplitude’);
subplot(3,2,3)
Har _ 123=Harmonic _ 1+Harmonic _ 2+Harmonic _ 3;
plot(t,Har _ 123);
title(‘Fund.+2nd.+3rd Harmonics’);
ylabel(‘Amplitude’);
subplot(3,2,4)
Har _ 1234=Harmonic _ 1+Harmonic _ 2+Harmonic _ 3+Harmonic _ 4;
plot(t,Har _ 1234);
title(‘Fund.+2nd.+3rd.+4th.Harmonics ‘);
ylabel(‘Amplitude’);
subplot(3,2,5);
Har _ 12345=Har _ 1234+Harmonic _ 5;
plot(t,Har _ 12345)
title(‘Fund.+2nd.+3rd.+4th.+5th.Harmonics ‘);
axis([0 2 -.55 .55])
ylabel(‘Amplitude’);
xlabel(‘time (in sec)’);
subplot(3,2,6);
Har _ 123456=Har _ 12345+Harmonic _ 6;
Free download pdf