简体   繁体   English

Matlab,运算符A \\ B.

[英]Matlab, operator A\B

What is the result of the operation A\\B, where A(1, m) and B (1, m)? 操作A \\ B的结果是什么,其中A(1,m)和B(1,m)?

In the manual it is written: 在手册中写道:

A\B returns a least-squares solution to the system of equations A*x= B.

So it means x = inv (A'*A)*A'*B? 所以它意味着x = inv(A'* A)* A'* B? However, the matrix A'*A is singular... 但是,矩阵A'* A是单数的......

Let us suppose: 让我们假设:

A=[1 2 3]
B=[6 7 6]
A\B

0         0         0
0         0         0
2.0000    2.3333    2.0000

If ve use MLS: 如果使用MLS:

C = inv (A'*A)   singular matrix
C = pinv(A'*A)

0.0051    0.0102    0.0153
0.0102    0.0204    0.0306
0.0153    0.0306    0.0459

D= C*A'*B

0.4286    0.5000    0.4286
0.8571    1.0000    0.8571
1.2857    1.5000    1.2857

So results A\\B and inv (A'*A)*A'*B are different... 所以结果A \\ B和inv(A'* A)* A'* B是不同的......

My MATLAB (R2010b) says quite a lot about what A\\B does: 我的MATLAB(R2010b)说了很多关于A\\B作用:

mldivide(A,B) and the equivalent A\\B perform matrix left division (back slash). mldivide(A,B)和等效的A\\B执行矩阵左划分(反斜杠)。 A and B must be matrices that have the same number of rows, unless A is a scalar, in which case A\\B performs element-wise division — that is, A\\B = A.\\B . AB必须是具有相同行数的矩阵,除非A是标量,在这种情况下A\\B执行逐元素除法 - 即A\\B = A.\\B

If A is a square matrix, A\\B is roughly the same as inv(A)*B , except it is computed in a different way. 如果A是方阵,则A\\Binv(A)*B大致相同,除非它以不同的方式计算。 If A is an n -by- n matrix and B is a column vector with n elements, or a matrix with several such columns, then X = A\\B is the solution to the equation AX = B . 如果An by- n矩阵, B是具有n元素的列向量,或者是具有多个这样的列的矩阵,则X = A\\B是等式AX = B的解。 A warning message is displayed if A is badly scaled or nearly singular. 如果A严重缩放或几乎是单数,则会显示警告消息。

If A is an m -by- n matrix with m ~= n and B is a column vector with m components, or a matrix with several such columns, then X = A\\B is the solution in the least squares sense to the under- or overdetermined system of equations AX = B . 如果Am by- n矩阵,其中m ~= nB是具有m分量的列向量,或者是具有多个这样的列的矩阵,那么X = A\\B是最小二乘意义下的解决方案。 - 或超定方程组AX = B In other words, X minimizes norm(A*X - B) , the length of the vector AX - B . 换句话说, X最小化norm(A*X - B) ,即矢量AX - B的长度。 The rank k of A is determined from the QR decomposition with column pivoting. A的等级k由具有列旋转的QR分解确定。 The computed solution X has at most k nonzero elements per column. 计算的解X每列最多具有k非零元素。 If k < n , this is usually not the same solution as x = pinv(A)*B , which returns a least squares solution. 如果k < n ,这通常与x = pinv(A)*B ,它返回最小二乘解。

mrdivide(B,A) and the equivalent B/A perform matrix right division (forward slash). mrdivide(B,A)和等效B/A执行矩阵右除(正斜杠)。 B and A must have the same number of columns. BA必须具有相同的列数。

If A is a square matrix, B/A is roughly the same as B*inv(A) . 如果A是方阵,则B/AB*inv(A)大致相同。 If A is an n -by- n matrix and B is a row vector with n elements, or a matrix with several such rows, then X = B/A is the solution to the equation XA = B computed by Gaussian elimination with partial pivoting. 如果An by- n矩阵, B是具有n元素的行向量,或者是具有多个这样的行的矩阵,那么X = B/A是通过高斯消除和部分旋转计算的等式XA = B的解。 。 A warning message is displayed if A is badly scaled or nearly singular. 如果A严重缩放或几乎是单数,则会显示警告消息。

If B is an m -by- n matrix with m ~= n and A is a column vector with m components, or a matrix with several such columns, then X = B/A is the solution in the least squares sense to the under- or overdetermined system of equations XA = B . 如果Bm m ~= nm by- n矩阵, A是具有m分量的列向量,或者是具有多个这样的列的矩阵,则X = B/A是最小二乘意义下的解决方案。 - 或超定方程组XA = B

x = inv (A'*A)*A'*B goes for over determined systems (ie which feature A as an nxm matrix with n>m ; in these circumstances A'A is invertible). x = inv (A'*A)*A'*B无二超定系统(即其中设有A作为nxm与矩阵n>m ;在这些情况下A'A是可逆的)。

In your case you have an under determined system. 在您的情况下,您有一个未确定的系统。


Thus, what may happen? 那么,会发生什么?

My opinion, although you can check, at least in your case : 我的意见,虽然你可以检查,至少在你的情况下

when you do A\\B matlab solves an optimization problem in the inverse sense wrt the usual least squares, that is 当你做A\\B matlab解决了与通常的最小二乘相反的优化问题,即

 X = argmin_{X \in S} ||X||,

where S is the set of solutions. 其中S是一组解决方案。 In other words, it gives you the solution of the system having minimum L^2 norm. 换句话说,它为您提供了具有最小L ^ 2范数的系统的解决方案。 (Consider that you can handle the problem by hands, at least in your case). (考虑到您可以手动处理问题,至少在您的情况下)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM