zhuan
zhuan

Reputation: 63

Solving N Equation with N variable Parametric in Matlab based on one of the variables

I am new in Matlab, I Have 3 equation like this:

-5*x + y + z == 0;

x - 2*y + z == 0;

x + y - z == 0;

I want to have the value of y and z based on x for example

z= 3*x

y= 2*x

can any one help me?

(if 'solve' (matlab command) can be used, please explain how?)one

Upvotes: 0

Views: 4842

Answers (1)

fpe
fpe

Reputation: 2750

A possible way to solve this question is by using the symbolic toolbox.

I would proceed as follows:

syms x y z real
assumptions(x)
assumptions(y)
assumptions(z)
f1 = '-5*x + y + z';
f2 = 'x - 2*y + z';
f3 = 'x + y - z';
Sol = solve(f1,f2,f3,'x,y,z');
Sol.x
Sol.y
Sol.z

The results are gonna be

Warning: The solutions are parametrized by the symbols:
u = R_

> In solve at 180 

ans =

u/3


ans =

(2*u)/3


ans =

u

This means that the triplet (x,y,z) will assume a different value depending on the value you assign to u, as for example

subs(Sol.x,1) = 0.3333

I hope this will clarify any doubt you may have.

Upvotes: 1

Related Questions