Review attached MATLAB Basics Dorfpdf file and do problems A
Solution
A.2
5x + 6y + 10z = 4
3x + 14z = 10
-7y + 21z = 0
In this problem we do not have the system of linear equations in the form AX = B.
use equationsToMatrix to convert the equations into the form AX=B.
Declare the system of equations.
syms x y z
eqn1 = 5*x + 6*y + 10*z == 4;
eqn2 = -3*x + 0*y + 14*z == 10;
eqn3 = -7*x + 0*y + 21*z == 0;
Use equationsToMatrix to convert the equations into the form AX = B.
The second input to equationsToMatrix specifies the independent variables in the equations.
[A,B] = equationsToMatrix([eqn1, eqn2, eqn3], [x, y, z])
A =
[ 5, 6, 10]
[ -3, 0, 14]
[ -7,0, 21]
B =
4
10
0
Use linsolve to solve AX = B for the vector of unknowns X.
X = linsolve(A,B)
X =
-16/11
93/77
31/77
From X, x = -16/17, y = 93/77 and z = 31/77
