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!