The standard Matlab ode45 call is:
[T,Y] = solver(odefun,tspan,y0,options);
But I also want the value of odefun
at each state vector Y
. It seems like there should be an option to return something like
[T,Y, DYDT] = solver(odefun,tspan,y0,options);
as this would be the most efficient way, since the routine already evaluates the derivative at each point internally. The obvious work around is to do
DYDT = odefun(T,Y);
however then I would need to write a modified version of odefun
since the one you pass to the solver
should be a column vector denoting a single state. Here obviously I am wanting to calculate DYDT
at all states Y
returned by the solver
. Any suggestions?