Why am I getting this error? The code works to solve the equation in terms of a and b for my teacher in class, but my professor is not having the issue. It solves for her.

32 views (last 30 days)
CODE:
syms a b x
solve('a*x^2 + b*x','b')
ERROR:
Error using solve>getEqns (line 418)
List of equations must not be empty.
Error in solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in Untitled (line 63)
solve('a*x^2 + b*x','b')

Answers (1)

Star Strider
Star Strider on 18 Apr 2018

Lose the single quotes and it will solve for you, too:

syms a b x
B = solve(a*x^2 + b*x, b)
B =
-a*x
  5 Comments
MURRAY GILBERTSON
MURRAY GILBERTSON on 20 Apr 2018
Edited: Walter Roberson on 16 May 2018
Character vectors as inputs to solve Errors
When specifying equations and variables, use symbolic equations and variables instead of character vectors. For example, replace solve('2*r = 1', 'r') with syms r; solve(2*r == 1, r).
Replace all instances of character vector input. Instead, create symbolic variables using syms, and then pass them as comma-separated input arguments, or as a vector of input arguments.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!