Timestep tracking in ode45
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
Respuesta aceptada
Más respuestas (2)
Rebecca Ward
el 3 de Nov. de 2011
0 votos
Walter Roberson
el 3 de Nov. de 2011
0 votos
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.
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!