필터 지우기
필터 지우기

problem in simulating an epidemic model using ode45

조회 수: 1 (최근 30일)
Ojaswita
Ojaswita 2013년 5월 10일
I am trying to solve and simulate an epidemic model using the guidelines provided by an online tutorial: Here is the function i have defined:
function ypsir = ypsir(t,y) a = 0.25; b = 0.000000908; k = 6; q = 22.02; m = 0.012; p = 0.45; l = 0.25; r = 0.14; ypsir(1) = q - m*y(1)-b*y(1)*y(5)+a*y(4); ypsir(2) = ((1-p)*b*y(1)*y(5))-((m+l)*y(2)); ypsir(3) = (b*p*y(5)*y(1))-((m+r)*y(3))+(l*y(2)); ypsir(4) = (r*y(3))-((m+a)*y(4)); ypsir(5) = ((y(5)/(y(5)+1000))*(exp(10*(y(2)+y(3)))))-(b*k*y(1)*y(5)) ypsir = [ypsir(1) ypsir(2) ypsir(3) ypsir(4) ypsir(5)]';
and i use the following m file to call the above function and plot my graphs:
clear; to = 0; tf = 50; yo = [200 20 20 10 1000000]; [t y] = ode45('ypsirtry',[to tf],yo); plot(t,y(:,1),t,y(:,2),t,y(:,3),t,y(:,4)) xlabel('time') ylabel('susceptible, infected, recovered')
but i am only getting straight lines... seems like the ode45 is not working and the graphs are being plotted for the initial values stated.
Can someone pls help

답변 (1개)

David Sanchez
David Sanchez 2013년 5월 10일
I tested your code and they are not straight lines, zoom in the plot to see it. Also, check the name of your function
function ypsir = ypsirtry(t,y)
....
...
Then
clear;
to = 0;
tf = 50;
yo = [200 20 20 10 1000000];
[t y] = ode45(@(t,y) ypsirtry(t,y),[to tf],yo);
plot(t,y(:,1),t,y(:,2),t,y(:,3),t,y(:,4))
xlabel('time')
ylabel('susceptible, infected, recovered')
Are you sure your system is what it should be?
  댓글 수: 1
Ojaswita
Ojaswita 2013년 5월 10일
Thanks alot for the help! I corrected my mistakes... I do think something is not correct with the system that is showing.. Is there any help I can get?

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

카테고리

Help CenterFile Exchange에서 Biological and Health Sciences에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by