t=(-2*pi*(1.0e-3)):1.0e-5:(2*pi*(1.0e-3));
Sum=0.5;  %this is the DC value
Omegao=1000;
for n=1:99  %repeat for a number of hamrmonics
    Exponent=((n-1)/2)
    Sum=Sum+(1/(n*pi))*sin(n*pi/2)*exp(i*n*Omegao*t)+(1/(n*pi))*sin(n*pi/2)*exp(-i*n*Omegao*t);
end
plot(t,Sum)
    