Timestep tracking in ode45
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Jan
el 3 de Nov. de 2011
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 comentarios
Más respuestas (2)
Walter Roberson
el 3 de Nov. de 2011
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.
2 comentarios
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!