Problems in the implementation of ODE45 in an epidemiological problem SIR

조회 수: 3 (최근 30일)
GTA
GTA 2018년 3월 15일
댓글: GTA 2018년 3월 16일
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
GTA
GTA 2018년 3월 15일
I looked at my code and realized a bug and fix it, but still, it still gives error! Can anyone help? Please find attached the codes with the modifications.
And the error now is this
>> ypsir_main
Error using feval
Undefined function 'ypsirtry' for input arguments of type
'double'.
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 6)
[t y] = ode45('ypsirtry',[to tf],yo);

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2018년 3월 16일
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
Torsten
Torsten 2018년 3월 16일
Try to use ODE15S instead of ODE45.
Best wishes
Torsten.
GTA
GTA 2018년 3월 16일
All right, thank you! So far he's running!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Electrical Block Libraries에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by