matlab+linsolve啥意思,[转载]linsolve 用法

linsolve

Solve linear system of

equations

Syntax

X = linsolve(A,B)

X = linsolve(A,B,opts)

Description

X = linsolve(A,B) solves the

linear system A*X = B using LU factorization with partial

pivoting when A is square and QR factorization with column pivoting

otherwise. The number of

rows of A must equal the number of rows of B. If

A is m-by-n and B is m-by-k, then X is

n-by-k. linsolve returns a warning if A is square

and ill conditioned or if it is not square and rank deficient.

[X, R] = linsolve(A,B) suppresses these warnings and

returns R, which is the reciprocal of the condition number

of A if A is square, or the rank of A if

A is not square.

X = linsolve(A,B,opts) solves the

linear system A*X = B or A'*X = B, using the

solver that is most appropriate given the properties of the matrix A, which you

specify in opts. For example, if A is upper

triangular, you can set opts.UT = true to make

linsolve use a solver designed for upper triangular

matrices. If A has the properties in opts,

linsolve is faster than mldivide, because

linsolve does not perform any tests to verify that

A has the specified properties.

Notes If A

does not have the properties that you specify in opts,

linsolve returns incorrect results and does not return an

error message. If you are not sure whether A

has the specified properties, use mldivide

instead.

For small problems, there is no speed benefit in using

linsolve on triangular matrices as opposed to using the

mldivide function.

The TRANSA field of the opts structure

specifies the form of the

linear system you want to solve:

If you set opts.TRANSA = false,

linsolve(A,B,opts) solves A*X = B.

If you set opts.TRANSA = true,

linsolve(A,B,opts) solves A'*X = B.

The following table lists all the field of opts and

their corresponding matrix properties. The values of the fields of

opts must be logical and the default value for

all fields is false.

Field Name

Matrix Property

LT

Lower triangular

UT

Upper triangular

UHESS

Upper Hessenberg

SYM

Real symmetric or complex Hermitian

POSDEF

Positive definite

RECT

General rectangular

TRANSA

Conjugate transpose — specifies whether the function solves

A*X = B or A'*X = B

The following table lists all combinations of field values in

opts that are valid for linsolve. A true/false

entry indicates that linsolve accepts either true or false.

LT

UT

UHESS

SYM

POSDEF

RECT

TRANSA

true

false

false

false

false

true/false

true/false

false

true

false

false

false

true/false

true/false

false

false

true

false

false

false

true/false

false

false

false

true

true/false

false

true/false

false

false

false

false

false

true/false

true/false

Example

The following code solves the system A'x = b for an

upper triangular matrix A using both mldivide and

linsolve.

A = triu(rand(5,3)); x = [1 1 1 0 0]'; b = A'*x;

y1 = (A')b

opts.UT = true; opts.TRANSA = true;

y2 = linsolve(A,b,opts)

y1 =

1.0000

1.0000

1.0000

0

0

y2 =

1.0000

1.0000

1.0000

0

0

Note If you are

working with matrices having

different properties, it is useful to create an options structure

for each type of matrix, such as opts_sym. This way you do

not need to change the fields whenever you solve a system with a

different type of matrix A.

See Also

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值