ODE45 continuous step inputs
16 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Ced
il 10 Mar 2016
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
il 10 Mar 2016
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.)
Risposte (0)
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!