orth
Orthonormal basis for range of matrix
Description
Examples
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
Because 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"). The reason is that the singular values of A are all nonzero.
Calculate the orthonormal basis for the range of A using orth.
Q = orth(A)
Q = 3×3
-0.1200 -0.8097 0.5744
0.9018 0.1531 0.4042
-0.4153 0.5665 0.7118
The number of columns in Q is equal to rank(A). Because A is full rank, Q and A are the same size.
Verify that the basis, Q, is orthogonal and normalized within a reasonable error range.
E = norm(eye(r)-Q'*Q,"fro")E = 1.0857e-15
The error is on the order of eps.
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
Because 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"). The reason is that 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
Because A is rank deficient, Q contains one fewer column than A.
When a matrix has small singular values, specify a tolerance to change which singular values are treated as zero.
Create a 7-by-7 Hilbert matrix. This matrix is full rank but has some small singular values.
H = hilb(7)
H = 7×7
1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429
0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250
0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111
0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000
0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 0.0909
0.1667 0.1429 0.1250 0.1111 0.1000 0.0909 0.0833
0.1429 0.1250 0.1111 0.1000 0.0909 0.0833 0.0769
Calculate an orthonormal basis for the range of H. Because H is full rank, Q and H are the same size.
Q = orth(H)
Q = 7×7
-0.7332 0.6232 0.2608 -0.0752 0.0160 -0.0025 0.0002
-0.4364 -0.1631 -0.6706 0.5268 -0.2279 0.0618 -0.0098
-0.3198 -0.3215 -0.2953 -0.4257 0.6288 -0.3487 0.0952
-0.2549 -0.3574 0.0230 -0.4617 -0.2004 0.6447 -0.3713
-0.2128 -0.3571 0.2337 -0.1712 -0.4970 -0.1744 0.6825
-0.1831 -0.3446 0.3679 0.1827 -0.1849 -0.5436 -0.5910
-0.1609 -0.3281 0.4523 0.5098 0.4808 0.3647 0.1944
Now, calculate the orthonormal basis vectors again, but specify a tolerance of 1e-4. This tolerance leads to orth treating three of the singular values as zeros, so the orthonormal basis has only four columns.
Qtol = orth(H,1e-4)
Qtol = 7×4
-0.7332 0.6232 0.2608 -0.0752
-0.4364 -0.1631 -0.6706 0.5268
-0.3198 -0.3215 -0.2953 -0.4257
-0.2549 -0.3574 0.0230 -0.4617
-0.2128 -0.3571 0.2337 -0.1712
-0.1831 -0.3446 0.3679 0.1827
-0.1609 -0.3281 0.4523 0.5098
Input Arguments
Input matrix.
Data Types: single | double
Complex Number Support: Yes
Singular value tolerance, specified as a real numeric scalar. Singular
values of A less than or equal to the tolerance are
treated as zero, which affects the number of column space vectors returned
by orth. The default tolerance is max(size(A))
* eps(norm(A)).
More About
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 because you can also write it as a linear combination of
the columns of A.
The rank of a matrix is equal to the dimension of the
range, and is equal to the number of nonzero singular values.
Algorithms
The orthonormal basis for the range of A is obtained from
U in the singular value decomposition [U,S] =
svd(A,"econ"). If r = rank(A,tol), then the first
r columns of U form an orthonormal basis for
the range of A.
Extended Capabilities
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.
Refer to the usage notes and limitations in the C/C++ Code Generation section. The same usage notes and limitations apply to GPU code generation.
The orth function fully supports
thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
The orth function
fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray (Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
The orth function fully supports
distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced before R2006aUse the tol argument to specify a tolerance threshold for the
singular values used to form the orthonormal basis for the range of
A. Singular values of the input matrix less than or equal to
the tolerance are treated as zero.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)