solving system of ODE until equilibrium for different parameter values

10 次查看(过去 30 天)
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 个评论
Torsten
Torsten 2016-6-22
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by