Undefined function 'minus' for input arguments of type 'sym'

This is my first time with the Symbolic Math Toolbox, 2012b. The following code
syms x y
[sol_x, sol_y] = solve(x^2 + y == 1, x - 2*y^2 == 2)
produces the error
Undefined function 'plus' for input arguments of type 'sym'.
What am I doing wrong? There were a lot of threads on roughly this subject, but I couldn't find one where the answer applied to my situation.
Thanks, Kurt

 Accepted Answer

There could be version differences between 2012a and 2013b (that I’m running here). (I don’t have access to 2012a any more, so I can’t test your code with it.)
Your code works fine for me as you posted it, and produces:
sol_x =
- 1.0997213367630765988805181024643 + 0.56837679138702087076241385221614*i
- 1.0997213367630765988805181024643 - 0.56837679138702087076241385221614*i
1.0997213367630765988805181024643 + 0.30938949574368425547005924661781*i
1.0997213367630765988805181024643 - 0.30938949574368425547005924661781*i
sol_y =
0.11366515845543691213299333209121 + 1.2501121696184858278179094827946*i
0.11366515845543691213299333209121 - 1.2501121696184858278179094827946*i
- 0.11366515845543691213299333209121 - 0.68048445967939729425829595210914*i
- 0.11366515845543691213299333209121 + 0.68048445967939729425829595210914*i

4 Comments

Maybe I'm missing something obvious. Is there something I have to do to invoke the Toolbox from the MATLAB prompt before I enter the first "syms" statement? Or perhaps I need to qualify the "solve" function, like "package::solve"? It is acting like it is a version of solve that accepts regular MATLAB variables instead of symbolic ones.
The only thing I could think of that would trigger the error you got is a version difference in the various editions of the Symbolic Math Toolbox. You may have to consult the documentation for 2012b to be sure your equations have the appropriate syntax for that release. Since you have the Symbolic Math Toolbox, you shouldn’t have to do anything special to invoke it. The ‘syms’ statement should do that.
The only other thing I can think of is that you wrote your own ‘solve’ function at some point. (This is known as ‘shadowing’ MATLAB functions.) Type
which solve -all
in the Command Window. When I do that, I get only:
C:\Program Files\MATLAB\R2013b\toolbox\symbolic\symbolic\solve.m
If you get something else in addition to that (or something like it), that could be your problem.
If you’re entering your commands in the Command Window, I suggest instead you put your commands in a script ‘.m’ file. That’s what I did. (I have a ‘scratchpad.m’ file that I use for short scripts and to test answers I post here.) Then just type the file name (with or without the ‘.m’ extension) in the Command Window. It should run without problems. You may have to put clear as the first command in the file so it will clear all the other variables in the workspace.
Thanks. "solve" wasn't shadowed. It turns out that I needed to have the equations in single quotes for 2012b. Then it worked!
My pleasure!
I remember that there were version changes, but I couldn’t remember what the syntax was in 2012b.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!