How to make ode15s not to cross zero?
2 ビュー (過去 30 日間)
古いコメントを表示
Here is the solution to a differential equation by simulink(ode15s, orange) and matlab(ode15s, blue). The solution mustn't cross Zero, how to prevent that in matlab ode15s?
0 件のコメント
採用された回答
Steven Lord
2018 年 7 月 6 日
Does your problem involve a mass matrix? If not, use the NonNegative option as shown in the Knee Problem example on this documentation page.
If your problem does involve a mass matrix, use an Events function as shown in the bouncing ball example and the three body problem example on this documentation page. In this case you'll need to stop the solver, recompute what the new "initial" conditions should be, determine if the differential equations themselves change, and restart the solver. In the case of the bouncing ball, the ballode.m file recomputes the initial conditions at each bounce to reflect the ball rebounding from the floor.
2 件のコメント
その他の回答 (1 件)
Torsten
2018 年 7 月 6 日
Tighten the tolerances RelTol and AbsTol, e.g.
opts = odeset('RelTol',1e-8,'AbsTol',1e-8);
Best wishes
Torsten.
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!