solving for multiple variables in matlab gives "Undefined Operator error"

时间:2017-12-18 05:44:21

标签: matlab

So yeah, what the above says, and whenever I try to run this, I get this error:

Undefined operator '-' for input arguments of type 'matlab.graphics.chart.primitive.Line'.

my code is:

a = x - y + z == 8;
b = 2*x + 3*y - z == -2;
c = 3*x - 2*y - 9*z == 9;
sol = solve([a, b, c], [x, y, z]);
fprintf("X value: ");
xval = sol.x;
disp(xval);
fprintf("Y value: ");
yval = sol.y;
disp(yval);
fprintf("Z value: ");
zval = sol.z;
disp(zval);

I really don't know what's going on, or how to do this, and it's for a project so I'd appreciate any help I can get c:

1 个答案:

答案 0 :(得分:0)

这对我有用

syms x y z
a = x - y + z == 8;
b = 2*x + 3*y - z == -2;
c = 3*x - 2*y - 9*z == 9;
sol = solve([a, b, c], [x, y, z]);
fprintf("X value: ");
xval = sol.x;
disp(xval);
fprintf("Y value: ");
yval = sol.y;
disp(yval);
fprintf("Z value: ");
zval = sol.z;
disp(zval);