0

I received a negative MATLAB response while inserting the following requests:

syms x y z
solve (x+y==z,x-2*y==z,[x,y],'ReturnConditions', false)

I wanted to get x, and y in terms of z but, alas, I got the following error:

??? Error using ==> char Conversion to char from logical is not possible.

Error in ==> solve>getEqns at 160 vc = char(v);

Error in ==> solve at 84 [eqns,vars] = getEqns(varargin{:});

Any help please?

Adriaan
  • 17,741
  • 7
  • 42
  • 75
Abr001am
  • 571
  • 6
  • 19

2 Answers2

2

Try using a cell array to wrap x and y instead:

>> syms x y z
>> X = solve (x+y==z,x-2*y==z,{x,y},'ReturnConditions', false);
>> X.x
ans =
z
>> X.y
ans =
0

This was required for previous versions of MATLAB. However, I'm using R2015a currently and your code works for me. I can't replicate your error. You may be using a previous version.

rayryeng
  • 102,964
  • 22
  • 184
  • 193
1

I think i found the hit-back to my problem.

As for solving system of two equations and two variables, we use a matrix of inputs, and outputs must be sprecified.

b=[x+y-z;x-3*y-z;]
b =

x + y - z
x - 3*y - z
[e t]=solve(b,x,y)
e =

z


t =

0

Thnk you all.

Abr001am
  • 571
  • 6
  • 19