1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| function dx=f(t, x, a)
dx (1) = a(t) - Pgamma*x(2)*(1-R) // dg/dt
dx (2) = x(3) - Pbeta*x(2) // di/dt
dx (3) = Pdelta*x(1) - Peta*x(1)^2 // dq/dt
endfunction
function [res]=a(t)
inter = 2;
larg = 1;
haut = 220;
res = zeros(1,length(t))
for i=1:length(t)
if modulo(t(i),inter)<=larg/2 | modulo(t(i),inter)>=inter-larg/2 then
if modulo(t(i),inter)>=inter-larg/2 then
x = modulo(t(i),inter) - (inter-larg/2);
elseif modulo(t(i),inter)<=larg/2
x = modulo(t(i),inter) + larg/2;
end
res(i) = haut*exp(-(x-larg/2)^2/(larg/(24)));
else
res(i) = 0;
end
end
endfunction
Pgamma = 1.82;
Pbeta = 1/25;
Peta = 1.05;
Pdelta = 90*Peta;
R = 0;
X0=[90;25;1]; //[g0;i0;q0]
t0=0;
t=0:0.005:3;
x=ode(X0,t0,t,f) |
Partager