. Advertisement .

..3..

. Advertisement .

..4..

How to fix “solve() throws this result Empty sym: 0-by-1 and fails to get the correct results”? Here is the code that I run:

```
syms v1 v2 v3
eqns = [5*v1 -2*v2 -3*v3 == 24, ...
4*v1 +5*v2 == 0, ...
-6*v1 +12*v2 +8*v3 == 0];
vars = [v1 v2 v3];
answer = solve(eqns,vars);
vpa(answer.v1)
vpa(answer.v2)
vpa(answer.v3)
```

```
ans =
Empty sym: 0-by-1
ans =
Empty sym: 0-by-1
ans =
Empty sym: 0-by-1
```

```
syms v1 v2 v3
eqn1 = 5*v1 -2*v2 -3*v3 == 24;
eqn2 = 4*v1 +5*v2 == 0;
eqn3 = -6*v1 +12*v2 +8*v3 == 0;
eqns = [eqn1,eqn2,eqn3];
vars = [v1 v2 v3];
answer = solve(eqns, vars);
vpa(answer.v1)
vpa(answer.v2)
vpa(answer.v3)
```

```
ans =
32.0
ans =
-25.6
ans =
62.4
```

Can someone share with me your knowledge and experience?

The cause:The reason of this error is from the following line:

If you run this line and write equations in the console, you will receive:

It says that there are actually 8 equations, not 3 equations. This is the reason why you don’t find any answers and the error happens.

Solution:To solve this error, you need to add several spaces. It seems that the sequence space->plus or minus sign->digit is interpreted as a new equation, which is a bizarre behavior. As a consequence, the program:

will give the accurate answer as below:

Line is the problem

This line can be executed and then entered eqns into console to get:

This is 8 equations rather than 3. This is why there is no solution. If you add spaces, the problem disappears. Strange behavior. It appears that the sequence space->plus/minus sign->digit can be understood as a new equation. Hence,

The correct answer will be returned: