solving system of ODE until equilibrium for different parameter values

10 visualizzazioni (ultimi 30 giorni)
I am trying to explore the equilibrium of a system of ODEs when tweaking different parameters. Currently, I have my ODE function (see SB1ode, below) and a function that calls the solver while passing the set of parameter values (SB1, below). I need help on how to tell the solver to stop at equilibrium, please, rather than at a fixed time. Thanks!
function [t,N] = SI1(s0,i0,Tmax,b,d,<more parameters>)
% Initial conditions
y0 = [s0 i0];
% parameters
P(1) = b;
P(2) = d;
P(3) = ... etc
% time steps
time = [0 Tmax];
% solve ODE system
[t,N] = ode45(@(t,Y) SI1ode(t,Y,P), time, y0);
end
function Y = SI1ode(t,x,P)
%parameters
b = P(1);
d = P(2);
...etc
%State variables
S = x(1);
I = x(2);
Y(1) = equation 1;
Y(2) = equation 2;
Y=Y'; %make column vector
end
And my running script is:
Tmax = 100;
s0 = 100;
i0 = 1e-2;
b = 2;
...etc
D = [0 .01 0.05 0.1 0.15 0.2 0.3 0.4 0.5 .6 .7 .8 .9 1];
for j=1:length(D)
d = D(j);
[t,N] = SI1(s0,i0,Tmax,b,d,<more parameters>);
result(j) = N(end,2)/(N(end,1)+N(end,2));
end
  2 Commenti
Renee
Renee il 21 Giu 2016
Did you ever find a solution? I am working on this problem too.
Torsten
Torsten il 22 Giu 2016
If you only search for the equilibrium state, use "fsolve" to solve for the stationary solution for your equations (i.e. delete the time derivatives).
Best wishes
Torsten.

Accedi per commentare.

Risposte (0)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by