ODE 45 intermediate value?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have an equation for ode45 that calculates the value of y1, y2 and y3. However, the differential equations include a variable 'a'. I would like this variable to change base don the intermediate values of the ode function. e.g. if the ode function calculates 10, then I want a = 0.5, and that value of a to be used in the rest of the calculation. How can I do this?
0 Commenti
Risposte (3)
Mohsen Davarynejad
il 11 Dic 2011
So the dynamics of your model changes based on the outcome of the model. Supose that when y(1) at time t1 gets above for instance .5, you like to change the model parameter, a.
My sugestion is to run the ODE45 with initial conditions y1, y2 and y3 at time t1 with the new parameter, a.
0 Commenti
Jan
il 11 Dic 2011
The question is not clear. What is an "intermediate" value? Which value is 10? What does "I want a=0.5" mean? What should happen before?
I guess, that you want an event function. This can be used to stop the integration at a certain point and restart it using new constants. Unfortunately ODE45 (and the other intergrators) cannot call a user-defined function or modify the paerameters directly, when an event occurs.
0 Commenti
Walter Roberson
il 11 Dic 2011
You can create a shared variable using nested functions, and access and update that variable within your calculating routine.
However! Remember that ode45 is a variable step-size solver, and that ode45 will go backwards in time if it decides that the time it stepped to is different enough that it needs intermediate points to smooth things out. Therefor updating "a" may cause problems: if ode45 steps back in time, you would be computing the prior points with an "a" that did not apply to them. And since changing "a" is going to essentially change the slope of your system, backward time steps to determine the boundary conditions become more likely.
1 Commento
Mohsen Davarynejad
il 11 Dic 2011
Your comment is true, and thats why I've suggested to start the calculation from t1 by recalling ODE45 with new initial values.
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!