Solve linear system of equations

`X = linsolve(A,B)`

`X = linsolve(A,B,opts)`

`[X,r] = linsolve(___)`

solves the linear system `X`

= linsolve(`A`

,`B`

)*A**X* = *B* using one of these methods:

When

`A`

is*square*,`linsolve`

uses LU factorization with partial pivoting.For all other cases,

`linsolve`

uses QR factorization with column pivoting.

`linsolve`

warns if `A`

is ill
conditioned (for square matrices) or rank deficient (for rectangular matrices).

uses an appropriate solver as determined by the options structure `X`

= linsolve(`A`

,`B`

,`opts`

)`opts`

.
The fields in `opts`

are logical values describing properties of the matrix
`A`

. For example, if `A`

is an upper triangular matrix,
you can set `opts.UT = true`

to make `linsolve`

use a
solver designed for upper triangular matrices. `linsolve`

does not test
to verify that `A`

has the properties specified in
`opts`

.

`[`

also returns `X`

,`r`

] = linsolve(___)`r`

, which is the reciprocal of the condition number of
`A`

(for square matrices) or the rank of `A`

(for
rectangular matrices). You can use any of the input argument combinations in previous
syntaxes. With this syntax, `linsolve`

does not warn if
`A`

is ill conditioned or rank deficient.

For small problems, using

`linsolve`

has no speed benefit as opposed to using the`mldivide`

function. The speed benefit with`linsolve`

arises by avoiding costly checks on the properties of large matrices.