solving system of ODE until equilibrium for different parameter values

조회 수: 11 (최근 30일)
Asaf
Asaf 2014년 7월 25일
댓글: Torsten 2016년 6월 22일
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
Renee
Renee 2016년 6월 21일
Did you ever find a solution? I am working on this problem too.
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