Documentation Center 
Factor arbitrary matrix into unitary and upper triangular components
The QR Factorization block uses a sequence of Householder transformations to triangularize the input matrix A. The block factors a column permutation of the MbyN input matrix A as
A_{e} = QR
The columnpivoted matrix A_{e} contains the columns of A permuted as indicated by the contents of lengthN permutation vector E.
A_{e} = A(:,E) % Equivalent MATLAB code
The block selects a column permutation vector E, which ensures that the diagonal elements of matrix R are arranged in order of decreasing magnitude.
The size of matrices Q and R depends on the setting of the Output size parameter:
When you select Economy for the output size, Q is an Mbymin(M,N) unitary matrix, and R is a min(M,N)byN uppertriangular matrix.
[Q R E] = qr(A,0) % Equivalent MATLAB code
When you select Full for the output size, Q is an MbyM unitary matrix, and R is a MbyN uppertriangular matrix.
[Q R E] = qr(A) % Equivalent MATLAB code
The block treats lengthM unoriented vector input as an Mby1 matrix.
QR factorization is an important tool for solving linear systems of equations because of good error propagation properties and the invertability of unitary matrices:
Q^{ –1} = Q'
where Q' is the complex conjugate transpose of Q.
Unlike LU and Cholesky factorizations, the matrix A does not need to be square for QR factorization. However, QR factorization requires twice as many operations as LU Factorization (Gaussian elimination).
The Output size parameter of the QR factorization block has two settings: Economy and Full. When the MbyN input matrix A has dimensions such that M > N, the dimensions of output matrices Q and R differ depending on the setting of the Output size parameter. If, however, the size of the input matrix A is such that M ≤ N, output matrices Q and R have the same dimensions, regardless of whether the Output size is set to Economy or Full.
The input to the QR Factorization block in the following model is a 5by2 matrix A. When you change the setting of the Output size parameter from Economy to Full, the dimensions of the output given by the QR Factorization block also change.
Open the model by typing ex_qrfactorization_refex_qrfactorization_ref at the MATLAB^{®} command line.
Doubleclick the QR Factorization block, set the Output size parameter to Economy, and run the model.
The QR Factorization block outputs a 5by2 matrix Q and a 2by2 matrix R.
Change the Output size parameter of the QR Factorization block to Full and rerun the model.
The QR Factorization block outputs a 5by5 matrix Q and a 5by2 matrix R.
Specify the size of output matrices Q and R:
Economy — When this output size is selected, the block outputs an Mbymin(M,N) unitary matrix Q and a min(M,N)byN uppertriangular matrix R.
Full — When this output size is selected, the block outputs an MbyM unitary matrix Q and a MbyN uppertriangular matrix R.
Golub, G. H., and C. F. Van Loan. Matrix Computations. 3rd ed. Baltimore, MD: Johns Hopkins University Press, 1996.
Port  Supported Data Types 

Input 

Output 

Cholesky Factorization  DSP System Toolbox 
LU Factorization  DSP System Toolbox 
QR Solver  DSP System Toolbox 
Singular Value Decomposition  DSP System Toolbox 
qr  MATLAB 
See Matrix Factorizations for related information.