主要内容

mrdivide,/

Solve systems of linear equationsxA = Bforx

Description

example

x=B/Asolves the system of linear equationsx*A = Bforx。矩阵ABmust contain the same number of columns. MATLAB®displays a warning message ifAis badly scaled or nearly singular, but performs the calculation regardless.

  • 如果Ais a scalar, thenb/a相当于B./A

  • 如果Ais a squaren-by-nmatrix andB是一个矩阵ncolumns, thenx = b/ais a solution to the equationx*A = B, if it exists.

  • 如果A是矩形m-by-nmatrix withm ~= n, 和B是一个矩阵ncolumns, thenx=B/Areturns a least-squares solution of the system of equationsx*A = B

x= mrdivide(B,A)is an alternative way to executex=B/A, but is rarely used. It enables operator overloading for classes.

Examples

collapse all

Solve a system of equations that has a unique solution,x*A = B

a = [1 1 3;2 0 4;-1 6 -1];b = [2 19 8];x = b/a
x =1×31.0000 2.0000 3.0000

解决一个不确定的系统,x*C = D

C = [1 0; 2 0; 1 0]; D = [1 2]; x = D/C
Warning: Rank deficient, rank = 1, tol = 1.332268e-15.
x =1×30 0.5000 0

MATLAB® issues a warning but proceeds with calculation.

Verify thatxis not an exact solution.

X*C-D
ans =1×20 -2

Input Arguments

collapse all

Operands, specified as vectors, full matrices, or sparse matrices.ABmust have the same number of columns.

  • 如果A或者B具有整数数据类型,另一个输入必须是标量。具有整数数据类型的操作数不能复杂。

Data Types:single|double|int8|INT16|int32|int64|uint8|uint16|uint32|uint64|logical|char
Complex Number Support:Yes

Output Arguments

collapse all

解决方案,作为向量,完整矩阵或稀疏矩阵返回。如果Ais anm-by-nmatrix andBis ap-by-n然后xis ap-by-mmatrix.

xis sparse only if bothABare sparse matrices.

提示

  • The operators/\are related to each other by the equationb/a= (A'\B')'

  • 如果A是一个方形矩阵,然后b/a大致等于B*Inv(A), but MATLAB processesb/a不同的和更坚固的。

  • Usedecomposition对象可以有效地用不同的右侧求解线性系统。decompositionobjects are well-suited to solving problems that require repeated solutions, since the decomposition of the coefficient matrix does not need to be performed multiple times.

Extended Capabilities

Version History

在R2006a之前引入