MATLAB: Unable to find symbolic solution warning

ode'ssolve

% Define function names that I wish to solve
syms x(t) y(t);
k1 = 0.02;
k2 = 0.00004;
k3 = 0.0004;
k4 = 0.04;
ode1 = diff(x) == k1*x-k2*x*y;
ode2 = diff(y) == k3*x*y-k4*y;
odes = [ode1;ode2];
S = dsolve(odes);
I keep getting a warning when I'm trying to solve this very simple system of odes.

Best Answer

It is nonllinear because of the ‘x*y’ terms, so it does not have an analytic solution that the Symbolic Math Toolbox can solve for.
Likely the only way to solve it is to use odeToVectorField and matlabFunction functions to create an anonymous function to use with the numeric ODE solvers, such as ode45 or ode15s:
[VF,Sbs] = odeToVectorField(odes);
odsefcn = matlabFunction(VF, 'Vars',{T,Y});
.