evenjc

[Python] Proof of Linearity

Aug 21st, 2019 (edited)
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # Importing the module pyplot from matplotlib
  4. import matplotlib.pyplot as plt
  5.  
  6. # Variables for our circuit. V will be generated in code
  7. # and used for calculation of I
  8. R = 100
  9. I = []
  10. V = []
  11.  
  12. # Function for generating voltages and calculating currents at those voltages
  13. def ramp_voltages():
  14.     for voltage in range(1,10):
  15.         V.append(voltage)
  16.         I.append(voltage/R)
  17.  
  18.  
  19. # Function for plotting the findings.
  20. def plotter():
  21.     plt.plot(V, I)
  22.     plt.grid()
  23.     plt.xlabel("Voltage [V]")
  24.     plt.ylabel("Current [A]")
  25.     plt.show()      
  26.        
  27. ramp_voltages()
  28. plotter()
Advertisement
Add Comment
Please, Sign In to add comment