Below is an implementation of the midpoint method in MATLAB for solving ordinary differential equations:
main.m577 chars24 linesThe function can be called by passing in the right-hand side function f, the time span tspan, the initial value y0 for the solution, and the step size h. The function returns a vector t of time steps and a vector y of corresponding solution values.
gistlibby LogSnag