import os
import matplotlib.pyplot as plt
import numpy as np
import scipy.integrate as si
os.chdir(r'D:\projects\wordpress\ex341')
os.getcwd()
def model1(y,t):
k = 0.1
dydt = -k*y
return dydt
def model2(y,t):
k = 0.5
dydt = -k*y
return dydt
inits = [5]
ts = np.linspace (0, 20)
ys1 = si.odeint(model1 , inits , ts)
plt.plot(ts,ys1)
ys2 = si.odeint(model2 , inits , ts)
plt.plot(ts,ys2)
plt.legend(['k=0.1','k=0.5'])
plt.savefig("ex341.png", dpi=100)
plt.show()
plt.close()
Like this:
Like Loading...
Related
Recent Comments