solving system of ODE until equilibrium for different parameter values
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Torsten
el 22 de Jun. de 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.
Respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!