Why is there a difference in computing least squares although same symbolic operator \ is used?
Show older comments
By reading the documentation and different answers to forum questions I am getting confused why some use cases of the \ operator (mldivide) compute least square solutions but others don't. For example, the documentation states that for a linear system Ax = b, x = A\b computes a least square solution if
- A is a rectangular m-by-n matrix with m ~= n, and B is a matrix with m rows, then A\B returns a least-squares solution to the system of equations A*x= B.
and so this is the case where x and B are vectors. But in the matrix case, A*X = B it is always explicitly stated that the symbolic operator \ does not compute least square solutions?
Some of my questions surrounding this:
- Why is there this difference?
- If I want a least square solution of AX = B, should I use X = lsqlin(A,B) instead?
- Can I vectorize AX = B to get vec(X) and new factor matrices C and D such that C*vec(X) = D (where D = vec(B)) and then perform vec(X) = D \ C to get a least square solution to my original matrix system?
3 Comments
Bruno Luong
on 3 Oct 2023
It is not not clear to me : do you have numerical matrices or symbolic?
Joppe De Jonghe
on 3 Oct 2023
Edited: Joppe De Jonghe
on 3 Oct 2023
Dyuman Joshi
on 3 Oct 2023
They are different functions that share the same name. The ** function is part of the Symbolic Math Toolbox.
You will find many functions that share the same name but have different functionality and are part of different Toolboxes. It's best to check the documentation to see if a function is built-in or not and how it operates.
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!