Empty sym: 0-by-1

Viewed 24

The code is like this:

syms x y z
eqns = [x + y == 1, x + z == 2, z - y == 0.5];
vars = [x y z];
[solx, soly, solz] = solve(eqns,vars)

But the result is like this:

solx =
 
Empty sym: 0-by-1
 
 
soly =
 
Empty sym: 0-by-1
 
 
solz =
 
Empty sym: 0-by-1

Why is this not working?

1 Answers

Let's recast your problem as a numerical linear algebra problem:

A = [1 1 0; 1 0 1; 0 -1 1];
b = [1; 2; 0.5];
result = A\b
result =

   1.00000
   0.16667
   0.83333

Aside from the result, you get a warning:

warning: matrix singular to machine precision

That should tell you the answer: your system is not solvable. You can determine the same thing manually by subtracting the first equation from the second:

  x + z == 2
- x + y == 1
-------------
  z - y == 1

This contradicts z - y == 0.5, so your system does not have a valid solution.

Related