Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

98 linhas
2.1KB

  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. ax(1) = 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. ax(end+1) = 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. ax(end+1) = 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. ax(end+1) = 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. linkaxes(ax)
  37. %% Triangular Wave
  38. amp = -(8*B)/(pi^2);
  39. tv = 0:T/50:2*T;
  40. ehv = amp*cos(w0*tv);
  41. dhv = (amp/9)*cos(3*w0*tv);
  42. vhv = (amp/25)*cos(5*w0*tv);
  43. rc = 4*B/T;
  44. T2 = T/2;
  45. T15 = 3*T/2;
  46. drv=[];
  47. for t=tv
  48. if (t<T2) drv=[drv -B+rc*t]; end
  49. if (T2<=t)&&(t<T) drv=[drv 3*B-rc*t]; end
  50. if (T<=t)&&(t<T15) drv=[drv -5*B+rc*t]; end
  51. if (T15<=t) drv=[drv 7*B-rc*t]; end
  52. end
  53. epdhv = ehv + dhv;
  54. epdpvhv = epdhv + vhv;
  55. figure(2);
  56. set(clf,'PaperType','A4');
  57. set(clf,'Color',[1,1,1]);
  58. ax(end+1) = subplot(221);
  59. plot(tv, drv, tv, ehv, tv, dhv, tv, vhv);
  60. xlabel('time [ms]','Fontsize',8);
  61. title('first three harmonics','Fontsize',8);
  62. set(gca,'Fontsize',8);
  63. ax(end+1) = subplot(222);
  64. plot(tv, drv, tv, ehv);
  65. xlabel('time [ms]','Fontsize',8);
  66. title('first harmonic','Fontsize',8);
  67. set(gca,'Fontsize',8);
  68. ax(end+1) = subplot(223);
  69. plot(tv, drv, tv, epdhv);
  70. xlabel('time [ms]','Fontsize',8);
  71. title('sum first and third harmonic','Fontsize',8);
  72. set(gca,'Fontsize',8);
  73. ax(end+1) = subplot(224);
  74. plot(tv, drv, tv, epdpvhv);
  75. xlabel('time [ms]','Fontsize',8);
  76. title('sum of all harmonics','Fontsize',8);
  77. set(gca,'Fontsize',8);
  78. linkaxes(ax(5:8))
  79. arrayfun(@(x) set(x,{'XGrid','YGrid'},{'on','on'}),ax)