Why doesn't SOLVE handle the case where the equation is just a constant variable?

1 view (last 30 days)
Why doesn't SOLVE handle the case where the equation is just a constant variable? For example:
>> [x,y]=solve('y','-x+y-y^3')
??? Error using ==> solve
1 variables does not match 2 outputs.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
SOLVE treats this expression as if you're trying to solve the single equation for y. So it believes that you have only one solution, but you have two output variables.
If you meant that you had two equations, you need to somehow indicate this in the call to SOLVE; the input parsing doesn't yet handle this case well. For example:
>> S = solve('y-0','-x+y-y^3')
S =
x: [1x1 sym]
y: [1x1 sym]
>> S.x
ans =
0
>> S.y
ans =
0
This has been reported to our development staff so that they can look into improving the way SOLVE handles this situation in a future release of the Symbolic Toolbox.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!