Tutorial 1
Tutorial 1
Topic: To determine the rank of a matrix and use it to solve a system of linear
equations using MATLAB
Much of MATLAB’s power comes from its matrix functions. These can be further separated into
two sub-categories. The first one consists of convenient matrix building functions, some of which
are given in the table below.
Sr. No. Function Description
Eye Identity matrix
zeros Matrix of zeroes
ones Matrix of ones
diag Extract diagonal of a matrix or create diagonal matrices
Triu Upper triangular part of a matrix
Tril Lower triangular part of a matrix
rand Randomly generated matrix
VI Steps to find solution of system of linear equations when it has infinitely many solution
Step -1 Enter the given system of linear equations.
Step-2 Find augmented matrix [A | B] by using function “equationsToMatrix”
Step -3 Check the rank of matrix A
Step-4 Check the rank of the augmented matrix [A | B]
Step -5 Determine number of variables (n) by using function “size(A,2)”
Step -6 Checks if the system has infinitely many solutions
Step -7 Solve using the function “solve”
Step -8 Display the solution
Step-9 Else Display the system either has no solution or infinite solutions.
Examples
B) Solve Following System of Linear Equation using concept of rank of the matrix:
1. 3𝑥 + 4𝑦 − 𝑧 = 2, 2𝑥 − 𝑦 + 3𝑧 = 1, 𝑥 + 2𝑦 + 𝑧 = 3
2. 𝑥 + 𝑦 − 𝑧 = 2 , 2𝑥 + 2𝑦 − 2𝑧 = 4, 3𝑥 + 3𝑦 − 3𝑧 = 6
3. 𝑥 + 2𝑦 − 𝑧 + 𝑤 = 4, 2𝑥 + 4𝑦 − 2𝑧 + 2𝑤 = 8, 𝑥 − 𝑦 + 𝑧 = 1
4. 5𝑥 + 2𝑦 − 𝑧 = 3, 2𝑥 + 4𝑦 − 2𝑦 = 7, 3𝑥 + 6𝑦 − 3𝑧 = 10
5. 𝑥 + 2𝑦 + 2𝑧 = 1, 2𝑥 + 2𝑦 + 3𝑧 = 3, 𝑥 − 𝑦 + 3𝑧 = 5
6. 2𝑥 − 3𝑦 + 5𝑧 = 1, 3𝑥 + 𝑦 − 𝑧 = 2, 𝑥 + 4𝑦 − 6𝑧 = 1