The lsq (or LSQ) command takes two arguments; a
matrix A and a vector or matrix B.
lsq returns the least squares solution to the equation
A*X = B.
Input:
Output:
Input:
Output:
Note that
Input:
Output:
since the linear system has no solution. We can still find the least
squares solution
Input:
Output:
The least squares solution
Input:
Output:
represents the point on the line 3x + 4y = 12 closest to the origin;
Input:
Output: