Warning: Unable to find symbolic solution. > In dsolve
5 views (last 30 days)
Show older comments

Hello, while writing the code, I got a Warning: Unable to find symbolic solution.
>In dsolve.
The code:
syms x(t) y(t)
a1=1;
a2=1;
b1=1;
b2=1;
b3=1;
b4=1;
b5=1;
ode1=diff(x) == a1*y - a2*x*y;
ode2=diff(y)== b1-b2*x*y - b3*y - b4*(y.^2) - b5*x*(y.^2);
[x,y]=dsolve(ode1,ode2,x(0)==0,y(0)==0);
fplot(subs(x),'r')
hold on
fplot(subs(y),'g')
The purpose of the task is to solve a system of differential equations and build graphs. Variables a and b I equated to one. x(0)=0,y(0)=0.
Tell me what's wrong?
Thank you
0 Comments
Answers (1)
Aabha
on 6 Feb 2025
Edited: Aabha
on 7 Feb 2025
Hi Denis,
The issue that you are facing may be because the system of equations in this case has a non-linear term - “x*y”. The function “dsolve” attempts to solve the equations symbolically. For certain non-linear systems, symbolic solvers might be unable to find a solution, or the solution might be too complex to express in closed form, which results in the warning message.
You can try using numeric solvers, such as “ode45” instead. The numeric solver takes in a MATLAB function handle as its input argument, which can be created using the “matlabFunction” function. Additionally, the function handle is created using a vector field, so you will need to convert the differential equations to a vector field first. Here is an example code to help you with this:
sys x(t) y(t);
a1 = 1;
a2 = 1;
b1 = 1;
b2 = 1;
b3 = 1;
b4 = 1;
b5 = 1;
ode1 = diff(x) == a1*y - a2*x*y;
ode2 = diff(y) == b1 - b2*x*y - b3*y - b4*(y.^2) - b5*x*(y.^2);
[VF, S] = odeToVectorField([ode1, ode2]); %convert the system to a vector field
f = matlabFunction(VF, 'Vars', {'t', 'Y'}); %create a MATLAB function handle from the vector field
Y0 = [0; 0];
tspan = [0 10];
[t, Y] = ode45(f, tspan, Y0);
x_sol = Y(:, 1);
y_sol = Y(:, 2);
You can refer to the following documentation if you need any further help.
0 Comments
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!