linsolve
Solve linear system of equations
Description
solves the linear system AX = B using one of these methods:X
= linsolve(A
,B
)
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.
Examples
Input Arguments
Output Arguments
Tips
The speed benefit of
linsolve
can vary depending on the matrix structure and the relative optimization of the underlying algorithms. In some cases (such as with small matrices) there might not be any speed-up compared tomldivide
. The speed benefit withlinsolve
arises by avoiding costly checks on the properties of large matrices, or by choosing an algorithm that is better suited to the input than the choice thatmldivide
makes.
Extended Capabilities
Version History
Introduced before R2006a