Florii11

rosu

Dec 16th, 2020 (edited)
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4.  
  5. x = np.array([0.8,1,1.2,1.4,1.6,1.8,2,2.2,2.4,2.6,2.8,3]);  
  6. # Potentialul de franare
  7.  
  8. F = np.array([6.8,8.3,9.8,11.3,12.8,14.4,15.9,17.4,18.9,20.3,21.7,23.1]);
  9. # Intensitatea
  10.  
  11. P = np.polyfit(x,F,1);
  12. # fiteaza (aproximeaza) datele cu un polinom de gradul 1
  13.  
  14.  
  15. Ffit = P[0]*x + P[1];
  16. # P[0] este panta iar P[1] este interesectia cu ordonata
  17.  
  18. plt.plot(x, F,'o', x ,Ffit,'-')
  19. # reprezinta datele experimetale si dreapta fitata
  20.          
  21. plt.title('Intensitatea in functie de potential')
  22. plt.xlabel('Vac(v)')
  23. plt.ylabel('I(μA)')
  24.  
  25. plt.grid(True)
  26.  
  27. plt.xlim((0,4))
  28. plt.ylim((-2,40))
  29.  
  30. txt = 'Panta: ' + str('{:.2f}'.format(P[0])) + ' μA/V'; # de scris pe grafic
  31. plt.text(3,10,txt);# scriu pe grafic
  32.  
  33. txt = 'Intersectia cu ordonata: ' + str('{:.2f}'.format(P[1])); # de scris pe grafic
  34. plt.text(2.3,6,txt);# scriu pe grafic
  35.  
  36. txt = 'I(V)=' + str('{:.2f}'.format(P[0])) + 'V+' +str('{:.2f}'.format(P[1])) + ' μA'; # de scris pe grafic
  37. plt.text(1,28,txt);# scriu pe grafic
  38.  
  39. txt = 'ROSU'; # de scris pe grafic
  40. plt.text(1.85,38,txt);# scriu pe grafic
  41.  
  42.  
  43. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment