ODE45 continuous step inputs
15 次查看(过去 30 天)
显示 更早的评论
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
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
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 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!