Open In App

Reduced Row Echelon Form (rref) Matrix in MATLAB

Reduced Row Echelon Form of a matrix is used to find the rank of a matrix and further allows to solve a system of linear equations. A matrix is in Row Echelon form if

Example :



A matrix can have several row echelon forms. A matrix is in Reduced Row Echelon Form if



Example:

Where a1,a2,b1,b2,b3 are nonzero elements.

A matrix has a unique Reduced row echelon form. Matlab allows users to find Reduced Row Echelon Form using rref() method. Different syntax of rref() are:

Let us discuss the above syntaxes in detail:

rref(A)

It returns the Reduced Row Echelon Form of the matrix A using the Gauss-Jordan method.

% creating a matrix using magic(n)
% generates n*n matrix with values
% from 1 to n^2 where every row sum
% is equal to every column sum
A = magic(4);
disp("Matrix");
disp(A);
  
% Reduced Row Echelon Form of A
RA = rref(A);
disp("rref :");
disp(RA);

                    

Output :

rref(A)

% creating a matrix using magic(n)
% generates n*n matrix with values 
% from 1 to n^2 where every row sum
% is equal to every column sum
A = magic(5);
disp("Matrix");
disp(A);
  
% Reduced Row Echelon Form of A
[RA,p] = rref(A);
disp("rref :");
disp(RA);
  
% Displaying pivot vector p
disp("Pivot vector");
disp(p);

                    

Output :

Finding solutions to a system of linear equations using Reduced Row Echelon Form:

The System of linear equations is 

Coefficient matrix A is 

Constant matrix B is 

Then Augmented matrix [AB] is 

% Coefficient matrix
A = [1  1  1;
     1  2  3;
     1  4  7];
       
% Constant matrix
b = [6 ;14; 30];
  
% Augmented matrix
M = [A b];
disp("Augmented matrix");
disp(M)
  
% Reduced Row echelon form of 
% Augmented matrix
R = rref(M);
disp("rref");
disp(R)

                    

Output :

Then the reduced equations are 

It has infinite solutions, one can be .


Article Tags :