Solving a system of coupled diferential equations using ODE15s

5 views (last 30 days)
I'm solving a large system of coupled differential equations using ODE15s. All variables are depending only on t. However, I've found conflicts when trying to solve the following:
x'=f(z')
y'=f(x',z')
z'=f(y')
In this case the derivatives of x(t),y(t),z(t) are in terms of the derivatives of each other. Therefore, when programming the ODE function. I reach the error of "using the variable before it's defined" or it makes one of the derivatives equal to zero. (Which is a trivial solution not relevant for my problem). I will appreciate some insights.
I want to use ODE solver if possible since is way faster than building solver from scratch. All the equations are thermodynamic variables as pressure, temperature and velocity of the gas, which are coupled.

Accepted Answer

Jose Julian Fierro Martinez
Solution was easier, yet trickier, than expected. At least for this case I did substitutions.
y'=f(x',z') --> y'=f( f(z'),z' ) --> y'= f( f( f(y')), f(y')) then everything was in terms of y' and variables, x,y,z. And the solver was capable of running without issues.

More Answers (1)

Torsten
Torsten on 1 Jun 2022
Use ODE15I instead of ODE15S.
Or use "fsolve" or "linsolve" to explicitly solve for x', y' and z' in the function where you return the derivatives for ODE15S.

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!