Help with coding a model
显示 更早的评论
Greetings,
I am currently trying to simulate an SI (SIR) model but everytime I get a new error and I do not know how to solve it from now on, could any one please help me?
The model is simple as the following:
With beta = 0.007
gamma = 0.01
L = 80
And 
Sigma = 0.115129254649702
I tried using Euler method and ode45 but with no luck, I am a bit confused on how to discretize just over time and inside the integral I should descritize over space
Here is my current code
syms x
L=80;
y=[0 L];
j = [0,L];
days = 10;
tspan = [1 10];
gamma=10^-2;
R_0 = 0.7;
beta=R_0*gamma;
epsilon = 0.0001;
sigma = -log(epsilon)/L;
Z0 = 0.2;
S0 = 1 - Z0;
[t,Z] = ode45(@(t,Z) odefun(Z,x,y,L,sigma,beta,gamma,days),tspan,Z0);
grid on;
hold on
function dZdt = odefun(Z,x,y,L,sigma,beta,gamma,days)
dZdt = zeros(L,days);
dZdt = beta*(1-Z)*int(exp(-sigma*abs(x-y))*Z(y),y,0,L) - gamma*Z;
end
Thank you in advance!
Have a nice day
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
