how to save only part of the solution when calling ODE routines
2 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I am solving a fairly large system of equations with ode113 but I only need part of the solution to be saved, otherwise a lot of memory is wasted. It seem that outputfcn can do such thing, but I cannot find a solid example. Could anyone help me on this topic? Thanks!
Bo
0 件のコメント
回答 (2 件)
Yu Jiang
2014 年 8 月 14 日
Hi Bo
From what I understand, you would like to save only a portion of the results obtained from ODE113.
A simple way to do it is to specify a series of time points at which you would like to save the answer, instead of only providing a time interval.
For example, let us define such a system
function dx = foo(t,x)
dx = sin(100*x);
end
To solve the system on the interval [0,1000], one can use the following code
x0 = 1;
[t,y] = ode113(@foo, [0 1000], x0);
From what I tested, y will be a matrix with 59857 rows.
But if you do the following
[t,y] = ode113(@foo, [0:1:1000], x0)
Then, y will only have 1001 rows.
However, in either way the executing time of ode113 will be the same, otherwise the simulation accuracy will be affected.
-Yu Jiang
0 件のコメント
参考
カテゴリ
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!