Define an additional variable in ODE solver

1 view (last 30 days)
Auwais Ahmed
Auwais Ahmed on 26 Nov 2021
Answered: Star Strider on 26 Nov 2021
I need to solve a system of ODE's. There are two time dependent concentrations equations
dC1/dt= Const1 + Const2 * P1
dC2/dt= Const3 + Const4 * P2
P1=f(r)
P2=g(r)
r= h(C1,C2)
I need to calculate P1 and P2 with are functions of r. Then calculate r using the solution of the differential equations for the latest time step. For this I would need an initial value for r to be used in first timestep. As equation for r is not an ODE how can I prescribe an initial condition for it?

Accepted Answer

Star Strider
Star Strider on 26 Nov 2021
This is all a bit confusing, since the differential equations are not them selves functions of ‘C1’ and ‘C2’, so a differential equation solver might not be necessary. Jus multiply ther RHS of those equations by the current value of ‘t’ an be done with it.
With respect to ‘r’ since it is a function of ‘C1’ and ‘C2’ that have initial conditions, calculate it, ‘P1’ and ‘P2’ first in each loop iteration.
At least, knowing only what is in the problem statement, that’s what I would do.
.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!