unexpected error for numeric::linsolve

3 次查看(过去 30 天)
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])

回答(1 个)

Walter Roberson
Walter Roberson 2018-5-23
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.

类别

Help CenterFile Exchange 中查找有关 Equation Solving 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by