import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt # function that returns dy/dt def model(y,t): # u steps from 0 to 2 at t=10 if t<10.0: u = 0 else: u = 2 dydt = (-y + u)/5.0 return dydt # initial condition y0 = 1…
An example of using ODEINT is with the following differential equation with parameter k=0.3, the initial condition y0=5 and the following differential equation. import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt # f…