MATLAB: Cannot solve system of differential equation HELP!!!!!

differential equationsystem of differential equation

I want to solve the above system of differential equation and plot s(t) and i(t), tried the following: (where beta=0.9, mu=0.015 and gamma=0.3, time step[0, 300], initial value for s(0) and i(0) are 0.4 and 0.6)
%
syms s(t) i(t)
eqn1 = diff(s) == -0.9*i*s+0.015-0.015*s;
eqn2 = diff(i) == 0.9*i*s-(0.3+0.015)*i;
c1 = s(0) == 0.4;
c2 = i(0) == 0.6;
[sSol(t) iSol(t)] = dsolve(eqn1, eqn2, c1, c2)
But it doesn't work / return [ empty sym ] Anyone know why please??
Your help means a lot to me, thanks!!

Best Answer

Use ode45:
% MAPPING: s = v(1), i = v(2)
ode = @(t, v, beta, mu, gamma) [-beta.*v(1).*v(2) + mu - mu.*v(1); beta.*v(1).*v(2) - (gamma + mu).*v(2)];
beta = 0.9; % Choose The Correct Values
mu = 0.015;
gamma = 0.3;
v_init = [0.4; 0.6];
tspan = linspace(1, 20, 50);
opts = odeset( 'OutputFcn','odephas2'); % Set To Plot Phase Plane
[t, v] = ode45(@(t,v) ode(t, v, beta, mu, gamma), tspan, v_init, opts);
figure(2)
plot(v(:,1), v(:,2)) % Plot The Phase Plane Manually
grid
for k1 = 1:length(t)
derivs(:,k1) = ode(t(k1), v(k1,:), beta, mu, gamma); % Calculate The Derivatives
end
figure(3)
plot(derivs(1,:), derivs(2,:)) % Plot Derivatives
grid
xlabel('^{ds}/_{dt}')
ylabel('^{di}/_{dt}')