How can I get ode solutions for the time steps I run the model instead of having values at the calculation time steps the solver chooses?
4 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I work with ordinary differential equations, which describe an aquatic food web. So I calculate biomasses. I have in my function file 3 ode’s and use ode45 to solve them. In my third ode I use the mean of the last 30 values of the values calculated in the first and second ode.
I run my model for 3000 time steps, which I defined as 1:1:3000. But the solver does not calculate the solutions of the ode’s in the same time steps. The solver uses small time steps, when the fluctuations of the calculated values are high and bigger steps, when the fluctuations are lower. So when my system is stable, it may happen, that the solver does not calculate values for each of my predefined time step.
The problem is now that I want to use for the calculations of the means (last 30 values of ode 1&2) not the last 30 values which were calculated by the solver, but the solutions of the ode’s of the 30 time steps I defined.
So my idea was to tell the solver to use for the calculations the time steps I defined. Does anybody know how to do this? Or do you maybe have another solutions for my problem?
I hope I explained my problem clearly, if there are any questions – please ask.
It would be great if anybody could help me!
Thanks, Betty
0 件のコメント
回答 (2 件)
Arnaud Miege
2011 年 6 月 22 日
tspan: A vector specifying the interval of integration, [t0,tf]. The solver imposes the initial conditions at tspan(1), and integrates from tspan(1) to tspan(end). To obtain solutions at specific times (all increasing or all decreasing), use tspan = [t0,t1,...,tf].
For tspan vectors with two elements [t0 tf], the solver returns the solution evaluated at every integration step. For tspan vectors with more than two elements, the solver returns solutions evaluated at the given time points. The time values must be in order, either increasing or decreasing.
HTH,
Arnaud
0 件のコメント
Betty Fritz
2011 年 6 月 23 日
1 件のコメント
Arnaud Miege
2011 年 6 月 28 日
I don't think you can access the internal time steps of the solver. You can control the step size with odeset though:
http://www.mathworks.com/help/releases/R2011a/techdoc/ref/odeset.html
参考
カテゴリ
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!