2.8 MATLAB: Solve Systems of Linear Equations Revisited
LAB ACTIVITY
2.8.1: MATLAB: Solve Systems of Linear Equations Revisited
This tool is provided by a third party. Though your activity may be recorded, a page refresh may be needed to fill the banner.
MATLAB: Solve Systems of Linear Equations Revisited
In this activity, you will use the inv() command to find the inverse of an invertible square matrix and use it to solve a system of linear equations.
Consider the linear system of equations:
2x + y = 4
x + 2v = 5
Create the coefficient matrix C.
C = [2, 1; 1, 2]
Create the column matrix d of constants. Remember, to create a column matrix, the rows are separated by semicolons.
d = [4; 5]
Use the inv() command to find the inverse of the matrix C.
invC = inv(C)
The solution to the linear system of equations is the inverse matrix times the column matrix of constants, provided the inverse of the square matrix C exists.
x = invC * d
Utilize the following linear system of equations for this activity.
2x1 + x2 + 2x3 = 0
1 + 3x2 + 2x3 = 4
3x1 = x2 + x3 = 3
Before submitting your solution, consider repeating the work above with the coefficient matrix A = [-2, 1, 2; 1, 3, 2; -1, 4, 4]. Do you run into any issues?
Script
Save C
Reset MATLAB Documentation
1%Create the coefficient matrix. Store the coefficient matrix in A.
2 3 sCreate the column matrix of constants. Store the column matrix of constants in b.
sUse the inv() command to find the inverse of the matrix A. Store the inverse matrix in invA.
6
%Find the solution to the linear system of equations using the inverse matrix, if the inverse matrix exists. If the inverse matrix exists, store the solution to the linear system of equations in x.
9 10 %Before submitting your solution, consider repeating the work above with the coefficient matrix A = [-2, 11, 12; 13]
Run Script