write a function that solves a system of linear


Write a function that solves a system of linear equations or calculates the inverse of a matrix by Gauss-Jordan elimination.  Your function should accept a matrix as an argument and return a matrix of the same dimension.

Note: Your function should be written to handle matrices of any size. Test your function with matrices of different sizes for which you know the solution to ensure that your function works correctly.

Use variable names that relate to their function and include comments that explain your program logic.

Do not use any built-in MATLAB functions except size(), input(), and zeros().

As example of what is expected from this function consider the following linear system:

3x + 2y + z = 11

2x + 3y +z = 13

x + y + 4z = 12

In this case you should pass into your function the following augmented matrix:

2341_calculates the inverse of a matrix by Gauss-Jordan elimination.png

After performing Gauss-Jordan elimination, your function should return the following reduced system:

1107_calculates the inverse of a matrix by Gauss-Jordan elimination1.png

from which we can readily determine that x = 1, y = 3, z = 2.

Furthermore, if you pass a double augmented matrix such as

1435_calculates the inverse of a matrix by Gauss-Jordan elimination2.png

Your function should return

441_calculates the inverse of a matrix by Gauss-Jordan elimination3.png

which solves the original equations

3x + 2y + z = 11

2x + 3y +z = 13

x + y + 4z = 12

as x = 1, y = 3, z = 2

and, at the same time, the equations

3x + 2y + z = -5

2x + 3y +z = -4

x + y + 4z = 9

as x = -2, y = -1, z = 3.

Additionally, if you pass to your function a square matrix on the left augmented by the identity matrix on the right, such as

705_calculates the inverse of a matrix by Gauss-Jordan elimination4.png

your function should return the identity matrix on the left and the inverse of the original square matrix on the right.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: write a function that solves a system of linear
Reference No:- TGS0484900

Expected delivery within 24 Hours