I'm having some trouble generating a square wave in matlab via my equation. Just wondering if anyone has some insight on what I am missing here in my code? I was thinking I could easily generate a square wave with just a few harmonics but it doesn't seem to be the case.
Thanks
x = 0:0.001:10; w = 2*pi*x; n = 5; wave = 0; for i = 1:2:n wave = wave + ((4*Vg)/(i*pi))*cos(i*w); end plot(x,wave)
thanks