pulse3a.sce 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. xdel(winsid())
  2. clear;
  3. t = [0:0.01:10];
  4. a = 1;
  5. b = 7;
  6. k = 1;
  7. magnitude = 100;
  8. offset = 20;
  9. y = k*(exp(-a*t) - exp(-b*t) );
  10. // Normalisera till 1 och multiplicera med magnituden
  11. y = y/max(y)*magnitude;
  12. ymax = max(y)*ones(1,length(y));
  13. // Create repetetive puses
  14. ylong=[];
  15. t=[];
  16. for i = [1:13]
  17. if(modulo(i, 7) == 0 || modulo(i, 7) == 1) // Skip two pulses
  18. ylong = [ylong zeros(1,length(y))];
  19. else // The rest are pulses
  20. ylong = [ylong y];
  21. end
  22. end
  23. // Add offset voltage and create t axis that fits all pulses
  24. ylong = ylong*-1;
  25. ylong = ylong + offset;
  26. t = [1:length(ylong)];
  27. // Plot vertical lines
  28. xpts = [1 1];
  29. ypts = [0.3*magnitude 0]+offset;
  30. plot(xpts*1000, ypts, '-');
  31. plot(xpts*5000, ypts, '-');
  32. plot(xpts*8000, ypts, '-');
  33. ypts = [0.15*magnitude 0]+offset;
  34. plot(xpts*2000, ypts, '-');
  35. //plot(xpts*8.96, ypts, '--');
  36. // Plot horizontal lines
  37. plot(ones(1,length(ylong))*min(ylong), '--blue'); // min
  38. plot(ones(1,length(ylong))*max(ylong), '--blue'); // Max
  39. plot(ones(1,length(ylong))*0, '-black'); // Zero
  40. plot(t,ylong, 'black'); // Självaste pulsen
  41. p = get("hdl");
  42. p = p.children;
  43. p.thickness = 3;
  44. // titletxt = ['$y = k(e^{-\alpha t} - e^{-\beta t})$' ; strcat(['$k=', string(k), ', \alpha=', string(a), ', \beta=', string(b), '$']) ];
  45. titletxt = '$y = k(e^{-\alpha t} - e^{-\beta t})$';
  46. //title("Consecutive pulses", 'fontsize', 8);
  47. //xlabel('t (s)', 'fontsize', 7);
  48. //ylabel('U (V)', 'fontsize', 7, 'rotation', 0);
  49. a = get("current_axes");
  50. a.axes_visible(1) = "off"; // Turn off X-axxis
  51. a.data_bounds = [min(t), -magnitude; max(t),offset*3];
  52. a.box = "off";
  53. f=get("current_figure")
  54. f.figure_size=f.figure_size*1.3 // Råkade bli lagom storlek