# 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`

,"econ")`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.

`[`

specifies whether to return the permutation information `Q`

,`R`

,`P`

] = qr(`A`

,`outputForm`

)`P`

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

is `"vector"`

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

. The default value of `outputForm`

is `"matrix"`

such that `A*P = Q*R`

.

`[___] = qr(`

is equivalent to
`A`

,0)`qr(A,"econ","vector")`

.

`[___] = 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`

,"econ")`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.

`[`

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

## Version History

**Introduced before R2006a**

## See Also

`lu`

| `chol`

| `null`

| `orth`

| `qrdelete`

| `qrinsert`

| `qrupdate`

| `decomposition`

| `lsqminnorm`

| `rank`