Matlab ODE45 with parameters which depend on the solution
조회 수: 1 (최근 30일)
이전 댓글 표시
I am trying to solve an ordinary differential equation with Matlabs ODE45 function. This works very fine with constant parameters. Now, I want to declare my parameters such that they depend on the solution at the last time step. The code looks like this
[t,q] = ode45(@ems,[t_begin t_end],initCondition);
In my function ems, there is a parameter which depends on q at the last time step. ODE45 solves my function for the entire time span. I am not interested in, how to "pause" the solver at each time step in order to assign the solution q to my function to be solved.
댓글 수: 0
답변 (2개)
Torsten
2017년 5월 19일
편집: Torsten
2017년 5월 19일
If you want to reset a parameter after each successful time step taken by the solver, you can use the "OutputFcn" routine (see the options structure of ODE45).
But note that MATLAB's ODE-integrators use adaptive time stepping. So the length of the time steps vary during integration. It might be better to use your own solver with fixed time stepping instead.
Best wishes
Torsten.
댓글 수: 5
Torsten
2017년 5월 22일
We don't know what function "var_k" does and how you call the ODE solver, but if "var_k" interpolates the value of k to the value of q(1), the code should work.
Best wishes
Torsten.
Jan
2017년 5월 22일
var_k(q(1),table) could mean in interpolation. If this is linear, remember that Matlab's integrators are designed to integrate differentiable functions only. Otherwise the stepsize controller is driven out of its purpose. See also http://www.mathworks.com/matlabcentral/answers/59582#answer_72047 .
Are you aware that the details about the function var_k matter the problem? Then it would be useful to show us, what happens inside this function.
댓글 수: 1
참고 항목
카테고리
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!