Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.35 KB | None | 0 0
  1. function sir =sir(t,y)
  2. a = .01;
  3. b = .1;
  4. sir(1) =-a*y(1)*y(2);
  5. sir(2) = a*y(1)*y(2)-b*y(2);
  6. sir(3) = b*y(2);
  7. sir = [sir(1) sir(2) sir(3)]';
  8.  
  9. to = 0;
  10. tf =14;
  11. yo = [763 1 0];
  12. [t y] = ode45('sir',[to tf],yo);
  13. plot(t,y(:,1),t,y(:,2),t,y(:,3))
  14. xlabel('time')
  15. ylabel('susceptible, infected, recovered')
  16. legend('susceptible', 'infected', 'recovered')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement