How to solve a system of two equations with 3 unknowns??

26 views (last 30 days)
My doubt is how to solve a system in which the number of equations is lower than the number of unknowns, using Matlab.
An example could be the following:
Solve the following system of equations:
x+3y-2z=7
5x-y+z=14
Thank you in advance!!

Answers (1)

Star Strider
Star Strider on 4 Feb 2019
I would do it the same way I would do it in secondary-school algebra:
syms x y z
Eq1 = x+3*y-2*z == 7 % Original Equation
Eq2 = 5*x-y+z == 14 % Original Equation
z1 = solve(Eq1,z) % Solve For ‘z’
z2 = solve(Eq2,z) % Solve For ‘z’
Eq1 = subs(Eq1,z, z2) % Substitute
Eq2 = subs(Eq2, z, z1) % Substitute
[Xs,Ys] = solve(Eq1, Eq2, [x,y]) % Solve For ‘x’ And ‘y’
There are an infinite number of solutions for the problem unless you eliminate one of the variables. Obviously, the one you eliminate (‘z’ here) can be any value.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!