def plottrajectories(fs, x0, t=np.linspace(1,400,10000), **kw):
"""
plots trajectory of the solution
f -- must accept an array of X and t=0, and return a 2D array of \dot y and \dot x
x0 -- vector
Example
=======
plottrajectories(lambda X,t=0:array([ X[0] - X[0]*X[1] ,
-X[1] + X[0]*X[1] ]), [ 5,5], color='red')
"""
x0 = np.array(x0)
#f = lambda X,t=0: array(fs(X[0],X[1]))
#fa = lambda X,t=0:array(fs(X[0],X[1]))
X = integrate.odeint( fs, x0, t)
plt.plot(X[:,0], X[:,1], **kw)
评论列表
文章目录