Matlab

How to Convert a Matrix into Reduced Row Echelon Form in MATLAB?

MATLAB, or Matrix Laboratory, is a programming language and environment designed specifically for technical computing that allows users to perform a wide variety of tasks, including matrix operations, data visualization, and simulation.

One of the most important matrix operations that MATLAB can perform is the reduced row echelon form of a matrix. The row reduced of a matrix is a special form of the matrix that can be used for a variety of purposes, such as determining the rank of the matrix and solving a system of linear equations.

This blog is going to address the query of how to convert a matrix into a reduced row echelon form in MATLAB.

What is a Matrix Reduced Row Echelon Form?

Before defining the reduced row echelon form of a matrix, we should know about the echelon form of a matrix.

If A is a matrix, it is in the echelon form if it satisfies the given conditions:

  • All zero rows of matrix A must be at the bottom.
  • The nonzero row of matrix A must have its first nonzero element on the right of the element present in the row above it.

Let’s define the reduced echelon form of the matrix:

A matrix A is called in the reduced echelon form if it satisfies the given conditions:

  • A must be in echelon form.
  • In each nonzero row of A, the first nonzero element (called the leading one) must be 1.
  • Each column of A containing a leading one must have zero entries except for that leading one.

How to Convert a Matrix into Reduced Row Echelon Form in MATLAB?

We can easily perform the reduced row echelon operation on a matrix in MATLAB using the rref() built-in function. This function accepts a matrix as an argument and returns its reduced row echelon form.

Syntax

The rref() function’s syntax is given below:

B = rref(A)

Here,

The function B = rref(A) yields to calculate the reduced row echelon form of the given symbolic matrix A using the Gauss-Jordan method.

Examples

To understand how to convert a matrix in the reduced row echelon form, consider some examples.

Example 1: How to Convert a Real Matrix into Reduced Row Echelon Form?

This example converts a real-valued matrix A into a reduced row echelon form using the rref() function in MATLAB.

A = magic(7);

B = rref(A)

Example 2: How to Convert a Complex Matrix into Reduced Row Echelon Form?

In this example, we convert a complex matrix A into a reduced row echelon form using the rref() function in MATLAB.

A = [1 -7i 9 5-7i; -i 0 1 3+i; 0 17 9-2i 11; 0 0 0 i];

B = rref(A)

Conclusion

MATLAB is a beneficial high-performance programming tool that has a huge library of built-in functions to perform complicated matrix operations. One such operation is converting a matrix into reduced row echelon form. The rref() function in MATLAB can be used to easily perform the reduced row echelon operation on a matrix. This guide has covered the basics of performing this operation, so you can now use the rref() function on any matrix to quickly convert it into its row-reduced echelon form.

About the author

Komal Batool Batool

I am passionate to research technologies and new ideas and that has brought me here to write for the LinuxHint. My major focus is to write on programming languages and computer science related topics.