Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

60 lignes
1.2KB

  1. clear;
  2. clc;
  3. fprintf('Fouriercomponenten of a triangle wave\n\n');
  4. B = input('Amplitude B of the triangle wave [V]: ');
  5. T = input('Period T of the triangle wave [ms]: ');
  6. fprintf('\n');
  7. w0 = 2*pi/T;
  8. amp = -(8*B)/(pi^2);
  9. tv = 0:T/50:2*T;
  10. ehv = amp*cos(w0*tv);
  11. dhv = (amp/9)*cos(3*w0*tv);
  12. vhv = (amp/25)*cos(5*w0*tv);
  13. rc = 4*B/T;
  14. T2 = T/2;
  15. T15 = 3*T/2;
  16. drv=[];
  17. for t=tv
  18. if (t<T2) drv=[drv -B+rc*t]; end
  19. if (T2<=t)&&(t<T) drv=[drv 3*B-rc*t]; end
  20. if (T<=t)&&(t<T15) drv=[drv -5*B+rc*t]; end
  21. if (T15<=t) drv=[drv 7*B-rc*t]; end
  22. end
  23. epdhv = ehv + dhv;
  24. epdpvhv = epdhv + vhv;
  25. figure(1);
  26. set(clf,'PaperType','A4');
  27. set(clf,'Color',[1,1,1]);
  28. subplot(221);
  29. plot(tv, drv, tv, ehv, tv, dhv, tv, vhv);
  30. xlabel('time [ms]','Fontsize',8);
  31. title('first three harmonics','Fontsize',8);
  32. set(gca,'Fontsize',8);
  33. subplot(222);
  34. plot(tv, drv, tv, ehv);
  35. xlabel('time [ms]','Fontsize',8);
  36. title('first harmonic','Fontsize',8);
  37. set(gca,'Fontsize',8);
  38. subplot(223);
  39. plot(tv, drv, tv, epdhv);
  40. xlabel('time [ms]','Fontsize',8);
  41. title('sum first and third harmonic','Fontsize',8);
  42. set(gca,'Fontsize',8);
  43. subplot(224);
  44. plot(tv, drv, tv, epdpvhv);
  45. xlabel('time [ms]','Fontsize',8);
  46. title('sum of all harmonics','Fontsize',8);
  47. set(gca,'Fontsize',8);