ode45

Imitate ode45 function from MATLAB in Python

拥有回忆 提交于 2019-12-04 20:16:47
I am wondering how to export MATLAB function ode45 to python. According to the documentation is should be as follows: MATLAB: [t,y]=ode45(@vdp1,[0 20],[2 0]); Python: import numpy as np def vdp1(t,y): dydt= np.array([y[1], (1-y[0]**2)*y[1]-y[0]]) return dydt import scipy integrate l=scipy.integrate.ode(vdp1([0,20],[2,0])).set_integrator("dopri5") The results are completely different, Matlab returns different dimensions than Python. The interface of integrate.ode is not as intuitive as of a simpler method odeint which, however, does not support choosing an ODE integrator. The main difference is