How to make ode15s not to cross zero?

조회 수: 1 (최근 30일)
Akbar
Akbar 2018년 7월 6일
댓글: Steven Lord 2018년 7월 6일
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?

채택된 답변

Steven Lord
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
Akbar
Akbar 2018년 7월 6일
편집: Akbar 2018년 7월 6일
Thank you for interesting solution. I am not using mass Matrix, and don't know if i Need it at all. I just know that the differential eq's is stiff, so i am using stiff solver, ode15s.
These are the Options i tries, and Matlab solution still crosses Zero. Seems like nonnegative thing didn't work. I wrote ones(1,14) because all 14 states should be nonnegative. I mean I have a 14 dimensional System.
options = odeset('RelTol',1e-6,'AbsTol',1e-6,'maxstep',0.2,'nonnegative',ones(1,14));
[t{ind},X{ind}] = ode15s(func,0:.01:170,X0,options);
Steven Lord
Steven Lord 2018년 7월 6일
Specify 1:14 as the value for the NonNegative option.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Torsten
Torsten 2018년 7월 6일
Tighten the tolerances RelTol and AbsTol, e.g.
opts = odeset('RelTol',1e-8,'AbsTol',1e-8);
Best wishes
Torsten.
  댓글 수: 2
Akbar
Akbar 2018년 7월 6일
That didn't help, I tried, thanks though.
Torsten
Torsten 2018년 7월 6일
What is the differential equation ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by