Integration time step in ODE45 Matlab

조회 수: 8 (최근 30일)
Chiara Vieceli
Chiara Vieceli 2023년 7월 13일
댓글: Steven Lord 2023년 7월 15일
Hello, I hope you can help me with this problem: I have to find out which is the time step used by the Matlab ode45 during integration. I have to set a value for the variable InitialStep through odeset, but I want to take a number which is similar to the time step used by the solver (I know it has a variable time step size, but I just need to discover the order of magnitude). I don't have to change or work on the output time interval, I am interested in knowing the integration time step size.
Thanks,
Chiara
  댓글 수: 2
James Tursa
James Tursa 2023년 7월 15일
Usually you don't have to do this, but in your case it is necessary? What differential equations are you solving?
Steven Lord
Steven Lord 2023년 7월 15일
In addition to James Tursa's question, how will your code handle the situation where the time step is negative? Yes, this can happen, if ode45 rejects a step and tries again with a smaller step. If it tries to step from t = 1 to t = 1.5, rejects it, then tries to step from t = 1 to t = 1.25 would that be detected as a time step of -0.25?

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

답변 (2개)

Jan
Jan 2023년 7월 13일
The output time interval is the integration interval, so you can grab it e.g. in the outputfcn.

Torsten
Torsten 2023년 7월 13일
편집: Torsten 2023년 7월 13일
If you use a two-element vector for tspan only giving the start and end time of integration, the values T(i+1)-T(i) (i=1,...,end-1) (computed from the array T returned by the solver) give the basic integration stepsizes taken. Of course, there will be function evaluations also in between the T-values due to the Runge-Kutta formulas.

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by