**orthonormal basis**of a given matrix. It’s a complicated as well as time-consuming problem while computing it manually. However, MATLAB permits us to perform this operation using the

**orth()**function.

This article is going to explore what is the **orthonormal basis** of a matrix and how to find them in MATLAB using the **orth()** function.

## What are the Orthonormal Basis of a Matrix

In Linear Algebra, the **orthonormal basis** of a vector space V having a finite dimension are the basis having **orthonormal vectors** where the **orthonormal vectors** are the unit vectors that are orthogonal to each other that is their dot product is zero.

Consider two-unit vectors x and y, they will be orthogonal to each other if **“x.y=0”**. These two vectors are also called **orthonormal vectors**.

## Why Do We Need to Calculate Orthonormal Basis

**An orthonormal basis** is useful in terms of finding the projection of a vector onto another vector or finding the distance between the two vectors. We can also use an **orthonormal basis **to reduce the round-off error in our simulations and the sole reason for this is that the vectors in an orthonormal basis are independent of each other, thus an error in one vector cannot propagate to other vectors. Further, finding coordinates and performing linear transformation is a lot easier if our basis is orthonormal.

## How to Find the Orthonormal Basis of a Matrix in MATLAB?

In MATLAB, we can find the **orthonormal basis** using the built-in **orth()** function which is responsible for determining the **orthonormal basis** of a given matrix. This function accepts a matrix as a mandatory parameter and provides a matrix as an output containing the **orthonormal basis** of the given input matrix.

**Syntax**

The **orth()** function can be implemented in MATLAB through the following syntaxes:

Q = orth(A,tol)

Here,

- The function
**Q = orth(A)**is responsible for determining the**orthonormal basis**for the range of A where columns of output matrix Q represent the**orthonormal basis**of the matrix A and they spam the range of matrix A. Also, the rank of A equals the count of columns of Q. - The function
**Q = orth(A,tol)**is responsible for determining the**orthonormal basis**for the range of A specifying the tolerance. The input matrix A’s singular values, which are less than tolerance, are treated as zero by affecting the number of columns of Q.

## Example 1: How to Find Orthonormal Basis of a Full Rank Matrix in MATLAB?

This MATLAB code determines the **orthonormal basis** of the given square matrix A having size n=3 using the **orth()** function. This code also finds the rank of a matrix A using the **rank()** function to verify that the input matrix is full rank.

r = rank(A)

Q = orth(A)

## Example 2: How to Compute the Orthonormal Basis of a Rank Deficient Matrix in MATLAB?

In this example, we use the **orth()** function to find the **orthonormal basis** of the given rank-deficient matrix A. The matrix A is rank deficient because **rank(K)<size(A)**.

r = rank(A)

Q = orth(A)

## Example 3: How to Find Orthonormal Basis of a Full Rank Matrix by Specifying Tolerance in MATLAB?

The given example computes the **orthonormal basis** of the given full-rank square matrix A having size **n=3** using the **orth()** function with default tolerance. As A is a full rank matrix, the size of A and Q **(orthogonal basis)** is the same, which is 3×3 in this case. The example then computes the **orthonormal basis** of A by specifying the value of tolerance 0.5 to consider the values of A that are less than 0.5 as singular values. There are three singular values in A, so A has two orthonormal column vectors as contained by the **Qtol** matrix.

r = rank(A)

Q = orth(A)

Q_tol = orth(A,0.5)

## Conclusion

Finding the **orthonormal basis** of a vector space is an important concept of linear algebra that is a complicated mathematical problem. However, it can be solved easily and efficiently by using MATLAB’s built-in **orth()** function. This article has presented the implementation of this function using different syntaxes and examples.