Define an additional variable in ODE solver

2 次查看(过去 30 天)
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?

采纳的回答

Star Strider
Star Strider 2021-11-26
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.
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by