problem in simulating an epidemic model using ode45
Mostra commenti meno recenti
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
Risposte (1)
David Sanchez
il 10 Mag 2013
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 Commento
Ojaswita
il 10 Mag 2013
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!