unexpected error for numeric::linsolve

3 views (last 30 days)
Colby Crenshaw
Colby Crenshaw on 23 May 2018
Answered: Walter Roberson on 23 May 2018
I am trying to solve a system of inequalities, and I am using the numeric::linsolve command but I keep getting an 'unexpected error' that says that the '::' usage is an invalid matlab syntax. Help?
numeric::linsolve({2*x + 2*y = 18, 1*x + 3*y = 12, 4*x + 3*y >= 24, z = .20*x + .25*y}, [x, y, z])

Answers (1)

Walter Roberson
Walter Roberson on 23 May 2018
Anything you see with "::" in its name can only be invoked from the Symbolic Engine. R2018a is the last release in which you can invoke
notebook
to get an interactive interface to execute the commands.
In the meantime, you can use
syms x y z
eqn = [2*x + 2*y == 18, 1*x + 3*y == 12, 4*x + 3*y >= 24, z == .20*x + .25*y];
sol = solve(eqn);
[sol.x, sol.y, sol.z]
This will give you single values.
With this particular system of inequalities, the single values are the only solution. However, in general when you solve() with inequalities, solve() might return a "representative" solution instead of indicating a range of solutions. The rules for which representative values are chosen are not documented, but I worked them out in the past and posted the rules.

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!