ODE45 continuous step inputs

조회 수: 14 (최근 30일)
Richard Sherrer
Richard Sherrer 2016년 3월 10일
댓글: Steven Lord 2016년 3월 10일
Hi All,
So I'm making a simple ode45 function but I would like to have the initial value be input continuously every x time units. Is there a way I can generalize this? For example, for a system of 6 equations, the inital value for y(1) is 2.9 and decays to zero after 5 time units. How can I reset the value of y(1) to 2.9 every 24 time units?
  댓글 수: 2
Ced
Ced 2016년 3월 10일
The most general way I can think of is to give the option of passing "event functions", as matlab does too. In each evaluation, the event function is checked, and if true, the event function is executed. In your case, that function would reset the value of y(1). Matlab then also stops the integration, but you can define how that is handled yourself.
If you are not familiar with the event functions, here is a little example (the matlab doc is very good too):
Steven Lord
Steven Lord 2016년 3월 10일
What exactly do you mean by the initial value decaying to zero after some number of time units? As the name implies, the initial value is used initially; the behavior after that is controlled by the ODE.
What you probably want to do is solve your ODE for time span [0 24] then use the final result at time t = 24 to generate new initial conditions for the next call to the ODE solver for the next day (assuming your "time units" are hours.)

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

답변 (0개)

카테고리

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