20 x - y + 12 z = 2 5 x + 3y - 10z = 30 x + 5z = -100the coefficient matrix a may be read off by ignoring the variable labels. Note that the order in which the variables appear must be the same in all of the equations. For example, the variable order in this example is x, y, z, and the coefficient matrix is:
20 -1 12 5 3 -10 1 0 5Note that there is a 0 in the y position in the bottom row. We may enter this system into MATLAB one row at a time, by typing the following commands at the MATLAB prompt:
a(1,:) = [20 -1 12] (press enter) a(2,:) = [5 3 -10] (press enter) a(3,:) = [1 0 5] (press enter)An alternative is to express the entire coefficient matrix in terms of its columns:
a = [ [20 5 1]' [-1 3 0]' [12 -10 5]' ] (press enter)The single quote character transposes a given row matrix, turning it into a column matrix as needed here.
The right-hand sides of the equations should be entered into a separate column vector (matrix) b:
b = [2 30 -100]'
a*v = bwhere a and b are the given matrices and v is the column matrix formed by the unknowns x, y, z.
v = a\bThis will load the solutions into the column matrix v. The solution procedure used by Matlab is Gaussian elimination with partial pivoting, as discussed in class.