many pulses.sce 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. xdel(winsid())
  2. clear;
  3. t = [0:0.01:10];
  4. a = 1;
  5. b = 2;
  6. k = 1;
  7. offset = 0;
  8. y = k*(exp(-a*t) - exp(-b*t) );
  9. ymax = max(y)*ones(1,length(y));
  10. // Create repetetive puses
  11. ylong=[];
  12. tlong=[];
  13. for i = [-1:11]
  14. if(modulo(i, 5) == 0) // Only each fifth should be pulse
  15. disp('yoman!')
  16. ylong = [ylong y];
  17. else // The rest is zero
  18. disp('shitdude!')
  19. ylong = [ylong zeros(1,length(y))];
  20. end
  21. end
  22. // Add offset voltage and create x axis
  23. ylong = ylong + offset;
  24. xlong = [1:length(ylong)];
  25. // Plot vertical lines
  26. xpts = [1 1];
  27. ypts = [-1 0];
  28. plot(xpts*1000, ypts, '--');
  29. plot(xpts*6000, ypts, '--');
  30. //plot(xpts*8.96, ypts, '--');
  31. // Plot lines
  32. plot(ylong, 'black');
  33. //plot(ones(1,length(ylong))*-.01, 'black');
  34. //plot(ones(1,length(ylong))*max(ylong)*1.01, 'black');
  35. //plot(t,ymax.*0.9, '--');
  36. // titletxt = ['$y = k(e^{-\alpha t} - e^{-\beta t})$' ; strcat(['$k=', string(k), ', \alpha=', string(a), ', \beta=', string(b), '$']) ];
  37. titletxt = '$y = k(e^{-\alpha t} - e^{-\beta t})$';
  38. title("Consecutive pulses", 'fontsize', 8);
  39. xlabel('t (s)', 'fontsize', 7);
  40. ylabel('U (V)', 'fontsize', 7, 'rotation', 0);
  41. a = get("current_axes");
  42. a.axes_visible = "off";
  43. //a.margins = [0 0 0 0];
  44. //a.zoom_box=[1,-0.01;10013,0.2524975];
  45. a.data_bounds = [1,-0.01;11500,0.2524975];
  46. //zoom_rect([-1,-1,1,1]);