How do I integrate the output of an ode23 solver?
2 views (last 30 days)
Show older comments
In my specific problem I have solved an ODE with ode23 resulting in two 11x1 double vectors (E and r). The dr's resulitng are equal in size, in this case. The integrate function does work on these variable types, or can it? Creating a simple "for" loop multiplying E(i)*dr and summing is too course (11 points) and gives the wrong answer, which I know exactly. The plotted output of ode23 shows a solid line between the 11 points. So, some kind of extrapolation or estimated function must exist, or? That then could be integrated with the function integrate, or?
0 Comments
Answers (2)
Torsten
on 25 Sep 2018
Solve the additional ODE
dI/dt = E(t)*dr/dt
then
I(T) = integral_{t=0}^{t=T} E(t) dr
Best wishes
Torsten.
0 Comments
Marc Jeroense
on 25 Sep 2018
1 Comment
Torsten
on 26 Sep 2018
If a quantity e is the result of a solution of an ODE
de/dt = ...
and in addition to e, you want to have the integral of e over time (name it E), you can add the differential equation
dE/dt = e, E(0)=0
to your system of ODEs.
Then
E(T) = integral_{t=0}^{t=T} e(t) dt
Best wishes
Torsten.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!