Updating variables within ODE function
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to update the values 'k0g,w0g,V0g' within the ODE function 'eval_dpardtau'.
Function call:
[tau,par] = ode45(@(tau,par) eval_dpardtau(tau,par,options,k0g,w0g,V0g),tauspan,par0);
Inside ODE function 'eval_dpardtau':
[k_0g,w_0g,V_0g] = eval_saddle_track(options,k0g,w0g,V0g);
Basically, I am using an iterative method ( fsolve) inside the function 'eval_saddle_track' for which I use the guess values 'k0g,w0g,V0g' to obtain the 'k_0g,w_0g,V_0g' values. After each time step (step in 'tau'), I want
k0g = k_0g;
w0g = w_0g;
V0g = V_0g;
so that at the next step, the iterative search in function 'eval_saddle_track' takes the updated guess value from the previous step, and NOT the initial value I pass with the call to 'ode45'.
I searched on the forum for a solution but could not find any. How can I pass the updated values of 'k0g,w0g,V0g' to 'eval_saddle_track'?
Thanks in advance.
EDIT#1: The values in structure 'options' are updated with the calculated value of 'par'.
0 commentaires
Réponses (1)
Torsten
le 12 Août 2016
ode45 can also solve for algebraic variables like k0g,w0g and V0g. So instead of iterating with fsolve, add the algebraic equations for k0g, w0g and V0g to the system to be solved by ode45 by using the mass-matrix option of the ODE solver.
Best wishes
Torsten.
2 commentaires
Torsten
le 12 Août 2016
But fsolve solves systems of algebraic equations, and these equations can be solved by ode45 together with the ordinary differential equations.
Best wishes
Torsten.
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!