Professional Documents
Culture Documents
Gauss Elimination Method
Gauss Elimination Method
Named after Carl Friedrich Gauss, Gauss Elimination Method is a popular technique of linear
algebra for solving system of linear equations. As the manipulation process of the method is
based on various row operations of augmented matrix, it is also known as row reduction
method. Gauss elimination method has various uses in finding rank of a matrix, calculation
of determinant and inverse of invertible matrix.
This source code is written to solve the following system of linear equation:
2x + y z = 8
-3x y + 2z = -11
-2x + y +2z = -3
Therefore, the value of A and B in the source code are fixed to be [2 1 -1; -3 -1 2; -2 1 2]
and [8 ; -11 ; -3 ]
Instead of creating a separate MATLAB file to define the function and give input, a single file
is designed to perform all the tasks. In order to solve other equation using this source code,
the user has to change the values of augmented matrices A and B defined in the source
code.
The sample output of the MATLAB program is given below:
M-File code
function X = elimination(X,i,j)
% Pivoting (i,j) element of matrix X and eliminating other column
% elements to zero
[ nX mX ] = size( X);
a = X(i,j);
X(i,:) = X(i,:)/a;
for k = 1:nX % loop to find triangular form
if k == i
continue
end
X(k,:) = X(k,:) - X(i,:)*X(k,j); % final result
end