close all
% Parameters

beta = 1;
alpha = .1;

par = [beta alpha]; % Creates vector of parameter values to pass to the ode solver

% % Alternatively: pass parameters as a structure
% par.alpha = alpha;
% par.beta = beta;

% Set up time vector (times at which you want the solution to the ODE calculated)

tspan = 0:.1:100; %(Note: can also use the function linspace)


% Define the Initial conditions
S0 = 100;
I0 = 1;
R0 = 0;

x0 = [S0 I0 R0]; % Creates vector of initial conditions

[t,x] = ode45(@SIR_model,tspan,x0,[],par); % Solve ode using MALTAB solver ode45.  Output is a time vector "t" and matrix of solutions "x".
    

% Plot solutions: (a couple ways to do this)

% plotting the "quick" way:

figure(1)

plot(t,x)
xlabel('Time in days')
ylabel('Number of individuals')
legend('S','I','R')

% --------

% plotting with more control:

S = x(:,1);
I = x(:,2);
R = x(:,3);

h = figure(2);

plot(tspan,S,'b','linewidth',2)
hold on
plot(tspan,I,'g','linewidth',2)
plot(tspan,R,'r','linewidth',2)

xlabel('Time in days')
ylabel('Number of individuals')
legend('S','I','R')

set(findall(h, '-property', 'FontSize'), 'FontSize', 16, 'fontWeight', 'bold')
