how ode solver works

29 次查看(过去 30 天)
nado
nado 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