Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

subplot(4,1,1);

t=pi/1100;
time1=-2*pi:t:2*pi;
signal=mod(time1/(2*pi), 1);
plot(time1,signal)
title('5a "Sawtooth Wave" ');
time1=0:t:2*pi;
signal=mod(time1/(2*pi), 1); %signal with lesser samples
for index=0:1:100 %FOr first 100 harmonics
arr(index+1) = (1/(2*pi))*sum(signal.*exp(-1i*index*time1))*t;
end
subplot(4,1,2)
harmonics_3=arr(1);
time1 = -2*pi:t:2*pi;
for index=1:1:3 % go upto the third harmonic
harmonics_3= conj(arr(index+1))*exp(-i*index*time1)+
harmonics_3+arr(index+1)*exp(i*index*time1);
end
plot(time1,abs(harmonics_3))
title(' 5b is handwritten and 3 Harmonics is the following');

harmoncis_7=arr(1);
for index=1:1:7
harmoncis_7= conj(arr(index+1))*exp(-i*index*time1) +
harmoncis_7+arr(index+1)*exp(i*index*time1);
end
subplot(4,1,3)
plot(time1,abs(harmoncis_7));
title('7 Harmonics');

harmonics_25=arr(1);
for index=1:1:25 % go upto the 25th harmonic
harmonics_25= conj(arr(index+1))*exp(-1i*index*time1)+
harmonics_25+arr(index+1)*exp(1i*index*time1);
end
subplot(4,1,4)
plot(time1,abs(harmonics_25));
title('25 harmonics');

You might also like