Empty sym solution when using symbolic solve() function

I got some trouble with the solve function: I have a system of equations with multiple variables, which I want to compute a symbolic solution for, for one variable only.
I was able to reproduce the problem with some simple code:
syms u v
eqns = [2*u^2 + v^2 == 0, u - v == 1];
solv = solve(eqns, v)
The answer I get is
solv =
Empty sym: 0-by-1
When solving for both u and v, I always get the right solution. I'm relatively new to MATLAB, does anybody see the problem?

回答 (1 件)

Prashant Arora
Prashant Arora 2017 年 4 月 26 日

0 投票

Hi Marc,
The reason you are seeing an empty solution is because the set of equations you are trying to solve does not have a valid symbolic solution. Given two equations with two variables, you will get a discrete set of solutions. Let's say you had two equations with 3 variables (x,y and z).
syms x y z
eqns = [x + y + z == 0, x^2 + y^2 + z^2 == 1];
To compute the solution of above equations symbolically, you need to specify which variable to serve as the "parameter". For example, to compute solution in terms of z (parameter), seek solutions for x and y.
solv = solve(eqns,x,y)

3 件のコメント

Francesco Giuseppe Fornari
Francesco Giuseppe Fornari 2018 年 2 月 6 日
I can't understand how, while using Matlab, expressions like the ones suggested at this link https://it.mathworks.com/help/symbolic/solve.html gives the same Empty sym: 0-by-1
To understand this issue while programming, I looked up for it, then tried this kind of symbolic equations, as
syms x
eqn = sin(x) == 1;
solx = solve(eqn,x)
(taken from the examples in that link) and, still, the program returns Empty sym: 0-by-1
I had to restart the program (clear and clc commands useless!)
Still I can't understand where is the problem in my script: also specifying wich variable to serve as the parameter, I have the same problem.
(here's the script I'm trying to set up: I want MatLab to display solutions for det(L)=0 in terms of alfa*l):
syms B v1(z1) v2(z2) p l c1 c2 c3 c4 c5 c6 c7 c8 alfa L c x
assume(B>0 & p ~=0 & l~=0 & alfa*l==x & p==alfa^2*B)
v1(z1)=c1*cos(alfa*z1)+c2*sin(alfa*z1)+c3*z1+c4
d1v1=diff(v1,z1);
d2v1=diff(v1,z1,2);
d3v1=diff(v1,z1,3);
d4v1=diff(v1,z1,4);
cond1=v1(0)==0;
cond2=v1(l)==0;
eqn1=-B*d2v1(0);
cond3=collect(eqn1,[c1,c2,c3,c4])==0;
eqn2=-B*d2v1(l);
cond4=collect(eqn2,[c1,c2,c3,c4])==0;
[L,noti]=equationsToMatrix([cond1,cond2,cond3,cond4],[c1,c2,c3,c4])
singolare_se=det(L)==0
[sol,params,conds]=solve(singolare_se,x,'ReturnConditions',true)
then, the equation to solve is
-B^2*alfa^4*l*sin(alfa*l) == 0
in terms of x=alfa*l
what can I do?
Sweta Das
Sweta Das 2022 年 5 月 3 日
I am also getting the same error. Have you resolved this issue?? Please let me know about the solution.
Chibuzo
Chibuzo 2022 年 7 月 12 日
I think you should set the solve() to return conditions. And you can also set it to return real solutions only. I just fixed a case my setting these parameters.
The older version would normal enforce these conditions and issue solutions with some warnings.

サインインしてコメントする。

タグ

質問済み:

2017 年 4 月 24 日

コメント済み:

2022 年 7 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by