clear all;

%y(1)=S, y(2)=I
% a=contagious parameter, b=recover parameter, 
% c=2nd time infection

a=0.3;b=0.15;c=0; 
F=@(t,y)[-a*y(1).*y(2)+c*(1-y(1)-y(2)); a*y(1).*y(2)-b*y(2)];

% solution curves for 4 different initial values

for i=1:4
    
figure(1);
[t,y]=ode45(F,[0 200],[0.5+0.1*i; 0.5-0.1*i]);
plot(t,y,'linewidth',1) 
hold on;

figure(2);
[S,I]=meshgrid(0:0.05:1,0:0.05:0.5);
Sp=-a*I.*S+c*(1-I-S);Ip=a*I.*S-b*I;
quiver(S,I,Sp,Ip);
hold on;
axis tight;
plot(y(:,1),y(:,2))

end

hold off;
