Q = orth(A) returns
an orthonormal basis for the range of A.
The columns of Q are vectors, which span the range
of A. The number of columns in Q is
equal to the rank of A.
Calculate and verify the orthonormal basis vectors for the range of a full rank matrix.
Define a matrix and find the rank.
A = [1 0 1;-1 -2 0; 0 1 -1];
r = rank(A)
r = 3
Since A is a square matrix of full rank, the orthonormal basis calculated by orth(A) matches the matrix U calculated in the singular value decomposition, [U,S] = svd(A,'econ'). This is because the singular values of A are all nonzero.
Calculate the orthonormal basis for the range of A using orth.
Calculate and verify the orthonormal basis vectors for the range of a rank deficient matrix.
Define a singular matrix and find the rank.
A = [1 0 1; 0 1 0; 1 0 1];
r = rank(A)
r = 2
Since A is rank deficient, the orthonormal basis calculated by orth(A) matches only the first r = 2 columns of matrix U calculated in the singular value decomposition, [U,S] = svd(A,'econ'). This is because the singular values of A are not all nonzero.
Calculate the orthonormal basis for the range of A using orth.
Q = orth(A)
Q = 3×2
-0.7071 0
0 1.0000
-0.7071 0
Since A is rank deficient, Q contains one fewer column than A.
The column space, or range,
of a matrix A is the collection of all linear combinations
of the columns of A. Any vector, b,
that is a solution to the linear equation, A*x = b,
is included in the range of A since you can also
write it as a linear combination of the columns of A.
Rank
The rank of a matrix is
equal to the dimension of the range.
Algorithms
orth is obtained from U in
the singular value decomposition, [U,S] = svd(A,'econ').
If r = rank(A), the first r columns
of U form an orthonormal basis for the range of A.
Extended Capabilities
C/C++ Code Generation Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Generated code can return a different basis than MATLAB® returns.
Code generation does not support sparse matrix inputs for this
function.
GPU Arrays Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).