You are on page 1of 8

MATLAB

SOLVING LINEAR EQUATIONS USING MATRICES


LECTURE OVERVIEW

• Determinates of Matrices.

• Cramer’s Rule.

• Example 1 – Using Cramer’s Rule.

• The Inverse of a Matrix.

• Example 1 Using the inverse matrix method.


DETERMINATES OF MATRICES

1 2 2 −1
𝐴= ,𝐵 =
3 4 2 0

det 𝐴 = 1𝑋4 − 3𝑋2 = −2

det 𝐵 = 2𝑋0 − 2𝑋 −1 = 2
In MATLAB

a=[1 2; 3 4];
b=[2 -1; 2 0]; % Define matrices a and b
det(a) % Compute the determinant of a
det(b) % Compute the determinant of b
CRAMER’S RULE
EXAMPLE 1 – USING CRAMER’S RULE

• For the system of the following equations compute


the unknowns x1,x2, and x3 using Cramer’s method.

2𝑥1 + 3𝑥2 + 𝑥3 = 0
𝑥1 + 2𝑥2 + 3𝑥3 = 6
3𝑥1 + 𝑥2 + 2𝑥3 = 8
THE INVERSE OF A MATRIX
EXAMPLE 1 – USING MATRIX INVERSE

• For the system of the following equations compute


the unknowns x1,x2, and x3 using matrix inverse
method.

2𝑥1 + 3𝑥2 + 𝑥3 = 9
𝑥1 + 2𝑥2 + 3𝑥3 = 6
3𝑥1 + 𝑥2 + 2𝑥3 = 8
EXAMPLE 1 – USING MATRIX INVERSE

• Solution
AX=B
2 3 1 𝑥1 9
𝐴=1 2 3 , 𝑥 = 𝑥2 , 𝐵 = 6
3 1 2 𝑥3 8

X=A\B
Or X=Inv(A)*B

You might also like