how ode solver works

조회 수: 23 (최근 30일)
nado
nado 2023년 3월 14일
댓글: John D'Errico 2023년 3월 14일
Hello everyone,
I am looking for knowing or displaying time step in ode solver. Therefore, I ran through a lot of questions asked on Mathworks community.
As a conclusion, il is impossible to know it or to display it. Now, my main question changes. Does anyone know how the ode works?
For example, a for loop executes the statements inside for a value of i then go to the top, increment i and then executes the statements.
a while loop does the same as for loop but it looks if the condition is false or not.
I hope that you understand what i am askin.
Best Regards,
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2023년 3월 14일
ode solvers incorporates algorithms to solve ODEs. The algorithms used can be found on the documentation page of the respective solvers.
nado
nado 2023년 3월 14일
Thank you for your suggestion!
But, this is not what i'm lookin for.

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

채택된 답변

Steven Lord
Steven Lord 2023년 3월 14일
I am looking for knowing or displaying time step in ode solver.
At what point during the solution process? If you're trying to control the step size or use the time step between the previous solver step and the current time in evaluating your ODE, those are not possible. In the former case the ODE solvers are adaptive solvers; they will choose the step size necessary to accurately take the step. In the latter, I think it highly unlikely that the mathematical form of your ODE include a delta-t term.
Therefore, I ran through a lot of questions asked on Mathworks community.
As a conclusion, il is impossible to know it or to display it.
You shouldn't care what steps the ODE solver internally chooses to take (some of which, I'd like to point out, the solver can reject.) If you care to have the solution returned or displayed at certain times that is possible.
To return the solution at specified times, specify the tspan input argument as a vector with more than 2 elements and the ODE solver will return the solution at those times. Alternately specify tspan as a two element vector, call the ODE solver with one output, and use deval to evaluate the solution at the desired times.
To display the solution after successful steps specify an OutputFcn in the ODE options. See the ballode and orbitode examples as they use an OutputFcn to visualize the path of the bouncing ball (ballode) or the orbiting bodies in the three-body problem (orbitode.)
Now, my main question changes. Does anyone know how the ode works?
Of course. Look at the Algorithms and References sections on the documentation pages for the ODE solvers like ode45. Alternately if the paper linked in the References section is too technical, Cleve Moler's Numerical Computing with MATLAB textbook has a chapter (the second longest in the book behind the introduction to MATLAB) on ordinary differential equations.
If you have a situation where you believe you need to know the time steps the ODE solver takes internally please provide more details about what you're doing. I can think of one case where you might think you need this information, and that's for solving delay differential equations. But in that case, don't use the ordinary differential equation solvers like ode45. Use the delay differential equation solvers like dde23 instead.
  댓글 수: 3
Steven Lord
Steven Lord 2023년 3월 14일
I'm curious how that dll would handle negative steps, which could happen if the ODE solver evaluated a potential step and decided to reject that step and try a smaller one if the original was too large to get an accurate solution.
John D'Errico
John D'Errico 2023년 3월 14일
Somehow I don't think an adaptive ODE solver, like ODE45, etc. may be the right tool here, as pointed out by @Steven Lord. Anyway, if your problem requires the step, then effectively, it is using a first order forward step, thus essentially just a forward Euler's method, at least for part of the solve.
So you may be better off just using a simple Euler method for the entire problem.

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

추가 답변 (1개)

Alan Stevens
Alan Stevens 2023년 3월 14일
doc ode45
Go to the References section. The two references listed will supply you with all you need to know about the ode solvers!
  댓글 수: 1
nado
nado 2023년 3월 14일
Thank you for your suggestion!
But, this is not what i'm lookin for.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by