Use the linfit function to model of a data set by a linear sum of terms. Each term consists of a function to fit and a coefficient calculated by linfit.
1. Define the following matrix.
2. Define a vector of functions to fit.
The model function is y(x) = c0 * ln(x) + c1 * sqrt x +c3.
3. Call the linfit function to calculate the coefficient for each function. Record the coefficients in vector c.
4. Define the fitting function f to be the linear combination of the functions in vf multiplied by the coefficients in c.
5. Plot the data points and the fitting function.
The linear combination of functions is a good fit to the data. This is confirmed by the value of the correlation coefficient which is close to 1: