How do I integrate the output of an ode23 solver?

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?

Réponses (2)

Torsten
Torsten le 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.
Marc Jeroense
Marc Jeroense le 25 Sep 2018

0 votes

I am afraid I do not quite understand you. I added my short trial file. Hope you can have a look? I now used the trapz function. I expected the result to be more accurate.

1 commentaire

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.

Connectez-vous pour commenter.

Produits

Version

R2018b

Commenté :

le 26 Sep 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by