To fit price1 vs index using different degrees of polynomials with MATLAB, you can use the polyfit
and polyval
functions.
Here's an example code using 1st, 2nd, and 3rd degree polynomials:
main.m646 chars32 lines
This code will plot the data points and the regression lines for 1st, 2nd, and 3rd degree polynomials.
Note: It's important to use caution when fitting higher degree polynomials as they can be prone to overfitting and may not generalize well to new data.
gistlibby LogSnag