필터 지우기
필터 지우기

Timestep tracking in ode45

조회 수: 1 (최근 30일)
Rebecca Ward
Rebecca Ward 2011년 11월 3일
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

채택된 답변

Jan
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.

추가 답변 (2개)

Rebecca Ward
Rebecca Ward 2011년 11월 3일
Thanks Jan,
I have a parameter within the ode function which is set according to how far through the simulation we are.
Specifically the simulation models heat flow through a building over a time period of 30 days. It is necessary to check for each day whether the step in question is between 8am and 8pm in which case the parameter (a set-point temperature) is changed. I understand that ODE45 itself sums the accepted timesteps, and I can generate the temperature outputs at the times I require, I just can't work out how to access the sum of accepted timesteps so I can modify the set-point temperature.
Thanks for your interest,
Rebecca

Walter Roberson
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.
  댓글 수: 2
Rebecca Ward
Rebecca Ward 2011년 11월 4일
Hi Walter,
Thanks for taking the time to answer - I originally assumed that t was the time since the beginning of the simulation but it doesn't monotonically increase, so that made me think it must be a timestep size. I'm OK with the set-point calculation once I have the time, I just can't work out how to extract the time value. Any more advice you could give would be great.
Thanks,
Rebecca
Rebecca Ward
Rebecca Ward 2011년 11월 4일
Hi again,
Seems to be working OK now - I was picking up t mid adaptive iteration, but the routine seems to assign t correctly to the parameters I'm specifying, so I think it's OK.
Thanks for your help,
Rebecca

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

카테고리

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