Created
October 27, 2020 17:20
-
-
Save alphaville/01171902213ee49779cc1500ac8e6e1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.integrate import solve_ivp | |
# constant control action: | |
u = 0.5 | |
# define the system dynamics | |
def system_dynamics(_t, z): | |
return [z[1], | |
-z[0]*z[1] + u] | |
t_final = 4 | |
z_init = [1, 1] | |
solution = solve_ivp(system_dynamics, [0, t_final], z_init, | |
t_eval=np.linspace(0, t_final, 100)) | |
plt.plot(solution.t, solution.y.T) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment