MATLAB: Does the polyfit() function in Matlab use Vandermonde-matrix and QR factorization method to solve a system of equations

polyfit

The polyfit() function in Matlab can be used for least-squares curve fit for any given polynomial order. The method used by Matlab is to construct the Vandermonde matrix and then solve it via QR factorization.
However, why doesn't Matlab use a more direct method for solving a system of linear equations using the conditions for least-squares fit and matrix-inversion methods such as Gauss-eliminaton?

Best Answer

The Gauss-elimiation works also, but the QR factorization is more stable here. I do not think that the method you sugeest is "more direct".
Related Question