Empty sym solution when using symbolic solve() function

조회 수: 125 (최근 30일)
Marc Kopf
Marc Kopf 2017년 4월 24일
댓글: Chibuzo 2022년 7월 12일
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일
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
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Equation Solving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by