How do I use the least squares approximation in MATLAB?

后端 未结 2 1362
南方客
南方客 2021-01-19 01:32

For a homework assignment in linear algebra, I have solved the following equation using MATLAB\'s \\ operator (which is the recommended way of doing it):

<
2条回答
  •  粉色の甜心
    2021-01-19 02:01

    mldivide, ("\") actually does that too. According to the documentation:

    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. In other words, X minimizes norm(A*X - B), the length of the vector AX - B. The rank k of A is determined from the QR decomposition with column pivoting (see Algorithm for details). The computed solution X has at most k nonzero elements per column. If k < n, this is usually not the same solution as x = pinv(A)*B, which returns a least squares solution.

    So really, what you did in the first assignment was to solve the equation using LSE.

提交回复
热议问题