Advertisement
Guest User

Untitled

a guest
May 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. %% Run me.
  2. close all; clc;
  3. T = 1;
  4. t = linspace(-T,T,1e5);
  5. N = 1;
  6. A0 = 0;
  7. A = zeros(1,N);
  8. B = zeros(1,N);
  9. x = A0*ones(size(t));
  10. for n = 1:N
  11. A(n) = 0;
  12. B(n) = ((-1)^(n+1))/(pi*n);
  13. x = x + A(n)*cos(2*pi/T*n*t) + B(n)*sin(2*pi/T*n*t);
  14. end
  15.  
  16. N2 = 3;
  17. A2 = zeros(1,N2);
  18. B2 = zeros(1,N2);
  19. x2 = A0*ones(size(t));
  20. for n = 1:N2
  21. A2(n) = 0;
  22. B2(n) = ((-1)^(n+1))/(pi*n);
  23. x2 = x2 + A2(n)*cos(2*pi/T*n*t) + B2(n)*sin(2*pi/T*n*t);
  24. end
  25.  
  26. N3 = 10;
  27. A3 = zeros(1,N3);
  28. B3 = zeros(1,N3);
  29. x3 = A0*ones(size(t));
  30. for n = 1:N3
  31. A3(n) = 0;
  32. B3(n) = ((-1)^(n+1))/(pi*n);
  33. x3 = x3 + A3(n)*cos(2*pi/T*n*t) + B3(n)*sin(2*pi/T*n*t);
  34. end
  35.  
  36. x4 = A0*ones(size(t));
  37. x4 = sawtooth(2*pi*(t-0.5))/2;
  38.  
  39. x5 = A0*ones(size(t));
  40. x5 = rms(x4-x);
  41.  
  42. %% Plot me
  43. figure;
  44. plot(t,x4);
  45. hold on;
  46. %plot(t, x2);
  47. %plot(t, x3);
  48. %plot(t, x4);
  49. plot(t, x5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement