f1=1/100;
t=linspace(0,200,2000);

s1=sin(t*2*pi*f1);
s3=sin(3*t*2*pi*f1)./3;
s5=sin(5*t*2*pi*f1)./5;
s7=sin(7*t*2*pi*f1)./7;

subplot(2,1,1)
plot(t,s1,'m')
title('A fundamental and three odd harmonics (3,5,7)')
hold('on')
plot(t,s3,'r');
plot(t,s5,'g')
plot(t,s7,'b')
grid('on')
legend('fund (freq 100)','3rd harm','5th harm','7th harmm')



subplot(2,1,2)
plot(t,s1,'m')
title('Sum of odd harmonics approximate square wave')
hold('on')
plot(t,s1+s3,'r');
plot(t,s1+s3+s5,'g')
plot(t,s1+s3+s5+s7,'b')
grid('on')
legend('fund (freq 100)','fund+3rd harm','fund+3rd+5th','fund+3rd+5th+7th')



grid('on')

figure
s=sin(t*2*pi*f1);
for i = 3:2:127
  s=s+(sin(i*t*2*pi*f1)./i);
end
plot(t,s);
grid('on')
title('Sum of odd harmonics from 1 to 127')





