필터 지우기
필터 지우기

Saving the derivative during solving ode functions

조회 수: 1 (최근 30일)
Hiep Dang
Hiep Dang 2012년 12월 11일
I have a question and hope that somebody came across this earlier. Your advice will be of great help. I have to solve a set of differential equations. They are coupled altogether, and look like this:
dw(1) = f(w(1),w(2),dw(2));
dw(2) = g(w(1),w(2),dw(1));
I don't want to get into details of f and g since they're quite long. The solution can be generated. However, besides w(1) and w(2) as the outputs, I also want to get dw(1) or dw(2), Is there anyway that I can use to achieve this. For some reasons, calculating the derivatives of w(1) and w(2) (after getting the outputs) is not desirable for this problem. What I want is somehow saving dw(1) and dw(2) in every time instant.
Thanks a lot for your help,

채택된 답변

Hiep Dang
Hiep Dang 2012년 12월 11일
Thanks Walter for your answer. However, I don't understand much about your recommendation.
It will involve with a "for" loop to call the dw after getting the output of t and w. It works for me at the moment, but will not be efficient because of the loop, especially when the ode function system is complicated.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 12월 11일
You could use an options structure with an OutputFcn specified. Exactly how you do the saving depends on what is convenient. For example, you could use a "global" cell array.
Note: time steps do not always go strictly forward. Sometimes, especially near boundary conditions, the ode solvers need to step backwards for greater accuracy.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by