No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

95 líneas
1.9KB

  1. %% Squarewave
  2. w0 = 2*pi/T;
  3. amp = 4*A/pi;
  4. tv = 0:T/50:2*T;
  5. ehv = amp*sin(w0*tv);
  6. dhv = (amp/3)*sin(3*w0*tv);
  7. vhv = (amp/5)*sin(5*w0*tv);
  8. blv = A*(sign(ehv));
  9. epdhv = ehv + dhv;
  10. epdpvhv = epdhv + vhv;
  11. maxamp=max(ehv);
  12. mA=ceil(maxamp);
  13. figure(1);
  14. set(clf,'PaperType','A4');
  15. set(clf,'Color',[1,1,1]);
  16. subplot(221);
  17. plot(tv, blv, tv, ehv, tv, dhv, tv, vhv);
  18. xlabel('time [ms]','Fontsize',8);
  19. title('first three harmonics','Fontsize',8);
  20. set(gca,'Fontsize',8);
  21. subplot(222);
  22. plot(tv, blv, tv, ehv);
  23. xlabel('time [ms]','Fontsize',8);
  24. title('first harmonic','Fontsize',8);
  25. set(gca,'Fontsize',8);
  26. subplot(223);
  27. plot(tv, blv, tv, epdhv);
  28. xlabel('time [ms]','Fontsize',8);
  29. title('sum first and third harmonic','Fontsize',8);
  30. set(gca,'Fontsize',8);
  31. subplot(224);
  32. plot(tv, blv, tv, epdpvhv);
  33. xlabel('time [ms]','Fontsize',8);
  34. title('sum of all harmonics','Fontsize',8);
  35. set(gca,'Fontsize',8);
  36. %% Triangular Wave
  37. amp = -(8*B)/(pi^2);
  38. tv = 0:T/50:2*T;
  39. ehv = amp*cos(w0*tv);
  40. dhv = (amp/9)*cos(3*w0*tv);
  41. vhv = (amp/25)*cos(5*w0*tv);
  42. rc = 4*B/T;
  43. T2 = T/2;
  44. T15 = 3*T/2;
  45. drv=[];
  46. for t=tv
  47. if (t<T2) drv=[drv -B+rc*t]; end
  48. if (T2<=t)&&(t<T) drv=[drv 3*B-rc*t]; end
  49. if (T<=t)&&(t<T15) drv=[drv -5*B+rc*t]; end
  50. if (T15<=t) drv=[drv 7*B-rc*t]; end
  51. end
  52. epdhv = ehv + dhv;
  53. epdpvhv = epdhv + vhv;
  54. figure(2);
  55. set(clf,'PaperType','A4');
  56. set(clf,'Color',[1,1,1]);
  57. subplot(221);
  58. plot(tv, drv, tv, ehv, tv, dhv, tv, vhv);
  59. xlabel('time [ms]','Fontsize',8);
  60. title('first three harmonics','Fontsize',8);
  61. set(gca,'Fontsize',8);
  62. subplot(222);
  63. plot(tv, drv, tv, ehv);
  64. xlabel('time [ms]','Fontsize',8);
  65. title('first harmonic','Fontsize',8);
  66. set(gca,'Fontsize',8);
  67. subplot(223);
  68. plot(tv, drv, tv, epdhv);
  69. xlabel('time [ms]','Fontsize',8);
  70. title('sum first and third harmonic','Fontsize',8);
  71. set(gca,'Fontsize',8);
  72. subplot(224);
  73. plot(tv, drv, tv, epdpvhv);
  74. xlabel('time [ms]','Fontsize',8);
  75. title('sum of all harmonics','Fontsize',8);
  76. set(gca,'Fontsize',8);