Skip to content

Instantly share code, notes, and snippets.

@AtlasPilotPuppy
Last active January 2, 2016 21:19
Show Gist options
  • Save AtlasPilotPuppy/8362969 to your computer and use it in GitHub Desktop.
Save AtlasPilotPuppy/8362969 to your computer and use it in GitHub Desktop.
python matplotlib example code.
from pylab import *
#create the function q(t) based on the question
def q(t):
if t < 0:
return 0
if t <= 10:
return 5 * t
if t <= 60:
return 60 - t
def q_array(t_array):
return [q(dt) for dt in t_array]
t_array = arange(0.0, 60.0, 1.0)
s = q_array(t_array)
plot(T,s)
xlabel('time - t (s)')
ylabel('charge - q (mC)')
grid(True)
savefig('question1_19.png')
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment