Timestep tracking in ode45
6 次查看(过去 30 天)
显示 更早的评论
Hi, Can anyone tell me how I would go about tracking the size of the timestep being used in the adaptive solver ode45?
What I need to do is to use a value for the absolue time in the equations being solved, and I was thinking I could do this by summing the timesteps, but I can't find a way to do this.
Any advice would be great - I'm a fairly new user of MATLAB.
Thanks a lot,
Rebecca
0 个评论
采纳的回答
Jan
2011-11-3
Of course ODE45 itself sums up the accepted time-steps. The simulation time is used as input of the ODE function.
Do you want to consider rejected steps? Perhaps it is getting clear, if you explain, what you want to achieve.
0 个评论
更多回答(2 个)
Walter Roberson
2011-11-3
The t passed to the fun function handle is the time since the beginning of the simulation. You know (ie. can control) the simulated clock time of the start of the simulation, so add the start clock time to the time offset, and convert the result to time of day. For example, seconds since 00:00, mod 24*60*60, between (8*60*60) and (20*60*60 minus epsilon) would be at one set point, otherwise the other set point.
You do not want to work with the sum of the timesteps, just with the current t (time since start) parameter. That and you might want to specify an explicit tspan list to ode45 so that ode45 calculates at your known boundaries rather than unknowingly stepping over a boundary.
另请参阅
类别
在 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!