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?
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Arnaud Miege
am 22 Jun. 2011
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 Kommentare
Betty Fritz
am 23 Jun. 2011
1 Kommentar
Arnaud Miege
am 28 Jun. 2011
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
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!