Integration of a function which is numerical solution of differential equation

71 views Asked by At

I've obtained a numerical solution of a differential equation in a form of a vector (i.e. M(170,1)) by using ode45, and tspan=0:500 (time range). How can I now integrate M(t)dt, when I am not sure how time sequences are distributed? I know, that I could put tspan=0:0.01:500, but I would like to save some time now.

1

There are 1 answers

0
Lutz Lehmann On

Add the integral to the differential system. If dM/dt=F(t,M) then the integral satisfies the differential equation dI/dt=M, that is d[M,I]/dt=[F(t,M), M].

This also gives for I a numerical integration of the same error order as for M.