Wanting all results for an algebraic equation that is within a function .

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)

Torsten
Torsten on 13 Feb 2026 at 16:45
Edited: Torsten on 14 Feb 2026 at 1:37
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.

Products

Release

R2025b

Asked:

on 13 Feb 2026 at 16:34

Edited:

on 14 Feb 2026 at 1:37

Community Treasure Hunt

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

Start Hunting!