# qr

QR decomposition

## Syntax

## Description

`[___] = qr(`

produces an
economy-size decomposition using any of the previous output argument combinations. The
size of the outputs depends on the size of `A`

,0)`m`

-by-`n`

matrix `A`

:

If

`m > n`

, then`qr`

computes only the first`n`

columns of`Q`

and the first`n`

rows of`R`

.If

`m <= n`

, then the economy-size decomposition is the same as the regular decomposition.If you specify a third output with the economy-size decomposition, then it is returned as a permutation vector such that

`A(:,P) = Q*R`

.

`[___] = qr(`

produces an economy-size decomposition using any of the previous output argument
combinations. The size of the outputs depends on the size of
`S`

,`B`

,0)`m`

-by-`n`

sparse matrix `S`

:

If

`m > n`

, then`qr`

computes only the first`n`

rows of`C`

and`R`

.If

`m <= n`

, then the economy-size decomposition is the same as the regular decomposition.If you specify a third output with the economy-size decomposition, then it is returned as a permutation vector such that the least-squares solution to

`S*X = B`

is`X(P,:) = R\C`

.

`[`

specifies whether to return the permutation information `C`

,`R`

,`P`

] = qr(`S`

,`B`

,`outputForm`

)`P`

as a matrix
or vector. For example, if `outputForm`

is `'vector'`

,
then the least-squares solution to `S*X = B`

is ```
X(P,:) =
R\C
```

. The default value of `outputForm`

is
`'matrix'`

such that the least-squares solution to ```
S*X =
B
```

is `X = P*(R\C)`

.

## Examples

## Input Arguments

## Output Arguments

## Tips

To solve multiple linear systems involving the same coefficient matrix, use

`decomposition`

objects.For the syntax

`[C,R] = qr(S,B)`

, the value of`X = R\C`

is a least-squares solution to`S*X = B`

only when`S`

does not have low rank.

## Extended Capabilities

## See Also

`lu`

| `chol`

| `null`

| `orth`

| `qrdelete`

| `qrinsert`

| `qrupdate`

| `decomposition`

| `lsqminnorm`

| `rank`

**Introduced before R2006a**