Unable to find symbolic solution warning

11 views (last 30 days)
% 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.

Accepted Answer

Star Strider
Star Strider on 3 Oct 2020
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});
.
  6 Comments
David Bloom
David Bloom on 12 Dec 2023
So how do I approach this problem then? In reality I have three initial conditions:
1)
2) positive value
3) which can be approximated as
I can live with choosing (2), but I'm not sure how to proceed with (1) and (3). Any thoughts?
David Bloom
David Bloom on 12 Dec 2023
Edited: David Bloom on 12 Dec 2023
I solved it myself and the issue comes down to the 1/r term. If you allow the interval to explicitly include r=0, then the symbolic solver fails to interpret it. However, if you change the interval from [0 20] to [1e-33 20] then it can indeed solve it.

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!