To compute the best fitting function using the least squares method, we can use the polyfit
function in MATLAB. The polyfit
function fits a polynomial of degree n
to the data using least squares method and returns the coefficients of the polynomial in decreasing order of powers.
Here's the MATLAB code to solve the problem:
main.m219 chars11 lines
Output:
main.m9 chars2 lines
Therefore, the value of the best fitting function at -7/2
is -64.6875
.
gistlibby LogSnag