%% Squarewave w0 = 2*pi/T; amp = 4*A/pi; tv = 0:T/50:2*T; ehv = amp*sin(w0*tv); dhv = (amp/3)*sin(3*w0*tv); vhv = (amp/5)*sin(5*w0*tv); blv = A*(sign(ehv)); epdhv = ehv + dhv; epdpvhv = epdhv + vhv; maxamp=max(ehv); mA=ceil(maxamp); clear ax figure(1); set(clf,'PaperType','A4'); set(clf,'Color',[1,1,1]); ax(1) = subplot(221); plot(tv, blv, tv, ehv, tv, dhv, tv, vhv); xlabel('time [ms]','Fontsize',8); title('first three harmonics','Fontsize',8); set(gca,'Fontsize',8); ax(end+1) = subplot(222); plot(tv, blv, tv, ehv); xlabel('time [ms]','Fontsize',8); title('first harmonic','Fontsize',8); set(gca,'Fontsize',8); ax(end+1) = subplot(223); plot(tv, blv, tv, epdhv); xlabel('time [ms]','Fontsize',8); title('sum first and third harmonic','Fontsize',8); set(gca,'Fontsize',8); ax(end+1) = subplot(224); plot(tv, blv, tv, epdpvhv); xlabel('time [ms]','Fontsize',8); title('sum of all harmonics','Fontsize',8); set(gca,'Fontsize',8); linkaxes(ax) %% Triangular Wave amp = -(8*B)/(pi^2); tv = 0:T/50:2*T; ehv = amp*cos(w0*tv); dhv = (amp/9)*cos(3*w0*tv); vhv = (amp/25)*cos(5*w0*tv); rc = 4*B/T; T2 = T/2; T15 = 3*T/2; drv=[]; for t=tv if (t