Piecewise ode15i

2 views (last 30 days)
Jan Filip
Jan Filip on 19 Feb 2021
Commented: Jan Filip on 19 Feb 2021
Suppose that given DAE system containing peicewise defined function.
What is more convenient way to call ode15i:
a) put conditional statements into function right into separate file (as daeFunction is capable to generate)
b) define solver event option and have bunch of DAE systems for each condition, than call them in adequate way?
I am missing this in documentation. Is there some issue with a) aproach?

Accepted Answer

Walter Roberson
Walter Roberson on 19 Feb 2021
Unfortunately, you need to use event functions and terminate the ode*() call at that location, and then start it up again from where it left off
It is not exactly the case that you cannot have any condition statements inside the function. However, for any one call to ode15i(), any condition statements you do have must be C2 (continuous second derivative.) I know very little about the math of ode15i() specifically, so I am not certain if it needs even higher continuity.
Sometimes it is easier to switch to integrating a different function handle; sometimes it is easiest to use the same function handle each time, but this time the piecewise happens to fall into a different branch.
A few weeks ago, we had someone who needed to have a force turned on during part of a quasi-periodic cycle. The exact times were a bit inconvenient to calculate in advance. So we used an event function to terminate, but we also used an additional parameter representing whether the force was to be turned on or off this cycle; http://www.mathworks.com/help/matlab/math/parameterizing-functions.html
  1 Comment
Jan Filip
Jan Filip on 19 Feb 2021
Excellent answear, thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Statics and Dynamics in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!