pulse3b.sce 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 = 40;
  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 + offset;
  25. t = [1:length(ylong)];
  26. // Plot vertical lines
  27. xpts = [1 1];
  28. ypts = [-0.2*magnitude 0]+offset;
  29. plot(xpts*1000, ypts, '-');
  30. plot(xpts*5000, ypts, '-');
  31. plot(xpts*8000, ypts, '-');
  32. ypts = [-0.1*magnitude 0]+offset;
  33. plot(xpts*2000, ypts, '-');
  34. //plot(xpts*8.96, ypts, '--');
  35. // Plot horizontal lines
  36. plot(ones(1,length(ylong))*min(ylong), '--blue'); // min
  37. plot(ones(1,length(ylong))*max(ylong), '--blue'); // Max
  38. plot(ones(1,length(ylong))*0, '-black'); // Zero
  39. plot(t,ylong, 'black'); // Självaste pulsen
  40. p = get("hdl");
  41. p = p.children;
  42. p.thickness = 3;
  43. // titletxt = ['$y = k(e^{-\alpha t} - e^{-\beta t})$' ; strcat(['$k=', string(k), ', \alpha=', string(a), ', \beta=', string(b), '$']) ];
  44. titletxt = '$y = k(e^{-\alpha t} - e^{-\beta t})$';
  45. //title("Consecutive pulses", 'fontsize', 8);
  46. //xlabel('t (s)', 'fontsize', 7);
  47. //ylabel('U (V)', 'fontsize', 7, 'rotation', 0);
  48. a = get("current_axes");
  49. a.axes_visible(1) = "off"; // Turn off X-axxis
  50. a.data_bounds = [min(t), 0; max(t),1.05*(magnitude+offset)];
  51. a.box = "off";
  52. f=get("current_figure")
  53. f.figure_size=f.figure_size*1.3 // Råkade bli lagom storlek