Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sir =sir(t,y)
- a = .01;
- b = .1;
- sir(1) =-a*y(1)*y(2);
- sir(2) = a*y(1)*y(2)-b*y(2);
- sir(3) = b*y(2);
- sir = [sir(1) sir(2) sir(3)]';
- to = 0;
- tf =14;
- yo = [763 1 0];
- [t y] = ode45('sir',[to tf],yo);
- plot(t,y(:,1),t,y(:,2),t,y(:,3))
- xlabel('time')
- ylabel('susceptible, infected, recovered')
- legend('susceptible', 'infected', 'recovered')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement