Solvind ODE with sudden change od dy/dt function
5 views (last 30 days)
Show older comments
Hi all, I have a problem. I am trying to solve an ODE with ode45, but the dy/dt function has to change abruptly at a certain time t_intermediate. How do you treat this problem? If I try to use two solver and pass to the second the last solution of the first one the solution seems not to be correct.
Is there a way to manage this?
Thanks!
1 Comment
Teja Muppirala
on 21 May 2012
Just as another suggestion, are you also familiar with Simulink? It is my experience that Simulink out-of-the-box can generally handle these sorts of problems easier than MATLAB.
But if you want to do it with ODE45, I think Jan has the right idea.
Answers (1)
Jan
on 21 May 2012
ODE45 requires a smooth function. Discontinuos changes of dy/dt let ODE45 reduce the stepsize until the rounding error exceeds the error caused by the jump. Finally the accumulated rounding errors will dominate the result.
Therefore you have to integrate from t_0 to t_intermediate and use the intermediate results as initial values of the integration from t_intermediate to t_end using the modified function.
It would be nice if the event functions are powerful enough to trigger such a change of the parameters, but they aren't.
See Also
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!