Updating variables within ODE function
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Torsten
el 12 de Ag. de 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 comentarios
Torsten
el 12 de Ag. de 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.
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!