Problems in the implementation of ODE45 in an epidemiological problem SIR
4 views (last 30 days)
Show older comments
Hello community, today I am trying to verify how my SIR epidemiologist model applied to yellow fever is behaving with some data entered. In this case in my program I took S = susceptible, I = infected, R = recovered, N = mosquitoes not carrying the virus and P = mosquitoes carrying the virus, using the ODE45 function. In this case I started with a population of 99 susctiveis people, one infected, one non-carrier mosquito and three carriers, in a time period of 0 to 50 days. That's all just to test if the program would run.
But when compilo I get the following error and I do not know how to fix it.
Undefined function or variable 'R'.
Error in ypsir (line 13)
ypsir(1) = sigmah*R - muh*S - betah*P*S + lambdah*(I+ R + S);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in ypsir_main (line 5)
[t y] = ode45('ypsir',[to tf],yo);
I know I'm missing out on something that may be relatively easy, but I'm starting to program now, so it may be that some technical terms that are said in the speech will not be understood, please try to be a little didactic.
The codes used are First part function ypsir =ypsir(t,y) betah = .01; muh = 0.01; sigmah = 0.05; alphah = 0.06; deltah = 0.05; mui = 0.07; mum = 0.07; betai = 0.03; lambdai = 0.06; lambdai = 0.5;
ypsir(1) = sigmah*R - muh*S - betah*P*S + lambdah*(I+ R + S);
ypsir(2) = -deltah*I - I*(alphah + muh) + betah*P*S;
ypsir(3) = deltah*I - sigmah*R;
ypsir(4) = -mui*N - mum*N1 - betai*I*N + lambdai*(N + P)*(1 - (N + P)/k);
ypsir(5) = betai*I*N - mui*P - mum*P;
ypsir = [ypsir(1) ypsir(2) ypsir(3) ypsir(4) ypsir(5)];
Second part
clear;
to = 0;
tf =50;
yo = [99 1 0 1 3];
[t y] = ode45('ypsir',[to tf],yo);
plot(t,y(:,1),t,y(:,2),t,y(:,3),t,y(:,4),t,y(:,5))
title('First Model of Yellow Fever')
xlabel('time')
ylabel('susceptible, infected, recovered,Mosquito Non-carrier, Mosquito
Carrier')
3 Comments
Accepted Answer
Torsten
on 16 Mar 2018
function ypsir = ypsirtry(t,y)
betah = .01;
muh = 0.01;
sigmah = 0.05;
alphah = 0.06;
deltah = 0.05;
mui = 0.07;
mum = 0.07;
betai = 0.03;
lambdai = 0.06;
lambdai = 0.5;
ypsir = zeros(5,1);
ypsir(1) = sigmah*y(3) - muh*y(1) - betah*y(1)*y(5) + lambdah*(y(2)+ y(3) + y(1));
ypsir(2) = -deltah*y(2) - y(2)*(alphah + muh) + betah*y(5)*y(1);
ypsir(3) = deltah*y(2) - sigmah*y(3);
ypsir(4) = -mui*y(4) - mum*y(4) - betai*y(2)*y(4) + lambdai*(y(4) + y(5))*(1 - (y(4) + y(5))/k);
ypsir(5) = betai*y(2)*y(4) - mui*y(5) - mum*y(5);
Best wishes
Torsten.
3 Comments
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!