Saving the derivative during solving ode functions
古いコメントを表示
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,
採用された回答
その他の回答 (1 件)
Walter Roberson
2012 年 12 月 11 日
0 投票
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.
カテゴリ
ヘルプ センター および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!