Updating variables within ODE function
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Torsten
2016 年 8 月 12 日
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 件のコメント
Torsten
2016 年 8 月 12 日
But fsolve solves systems of algebraic equations, and these equations can be solved by ode45 together with the ordinary differential equations.
Best wishes
Torsten.
参考
カテゴリ
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!