You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 line
1.0KB

  1. clear;
  2. clc;
  3. fprintf('Fouriercomponenten of a square wave\n\n');
  4. A = input('Amplitude A of the square wave [V]: ');
  5. T = input('Period T of the square wave [ms]: ');
  6. fprintf('\n');
  7. w0 = 2*pi/T;
  8. amp = 4*A/pi;
  9. tv = 0:T/50:2*T;
  10. ehv = amp*sin(w0*tv);
  11. dhv = (amp/3)*sin(3*w0*tv);
  12. vhv = (amp/5)*sin(5*w0*tv);
  13. blv = A*(sign(ehv));
  14. epdhv = ehv + dhv;
  15. epdpvhv = epdhv + vhv;
  16. maxamp=max(ehv);
  17. mA=ceil(maxamp);
  18. figure(1);
  19. set(clf,'PaperType','A4');
  20. set(clf,'Color',[1,1,1]);
  21. subplot(221);
  22. plot(tv, blv, tv, ehv, tv, dhv, tv, vhv);
  23. xlabel('time [ms]','Fontsize',8);
  24. title('first three harmonics','Fontsize',8);
  25. set(gca,'Fontsize',8);
  26. subplot(222);
  27. plot(tv, blv, tv, ehv);
  28. xlabel('time [ms]','Fontsize',8);
  29. title('first harmonic','Fontsize',8);
  30. set(gca,'Fontsize',8);
  31. subplot(223);
  32. plot(tv, blv, tv, epdhv);
  33. xlabel('time [ms]','Fontsize',8);
  34. title('sum first and third harmonic','Fontsize',8);
  35. set(gca,'Fontsize',8);
  36. subplot(224);
  37. plot(tv, blv, tv, epdpvhv);
  38. xlabel('time [ms]','Fontsize',8);
  39. title('sum of all harmonics','Fontsize',8);
  40. set(gca,'Fontsize',8);