Wanting all results for an algebraic equation that is within a function .
Show older comments
I have a function that is a system of ODEs. This function also contains several algebraic equations that are solved at each time step and contain the solutions to said ODEs to solve the algebraic equations. How can I "call" or "view" the solution at each time step to the algebraic equations?
Answers (1)
One method:
Define the algebraic variables as additional solution variables to the ODE system. This results in a DAE-system (i.e. a mixture of algebraic and ordinary differential equations) and the algebraic variables will automatically be included in the solution vector for the prescribed output times.
Take a look at the example "Solve Robertson Problem as Semi-Explicit Differential-Algebraic System (DAE)" under
to see how to proceed.
A second method:
Define the algebraic variables as a second output argument of the function in which you defined the ODE system. After the solver returned the ODE results, you can call this function in a loop for all the output times for which you got ODE results and return the algebaic variables to the calling program.
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!