You can fit a polynomial curve to your data using the "polyfit" and "polyval" functions in Matlab. Here's an example code snippet that fits a 4th degree polynomial curve to the "price1" vs "index" data:
main.m375 chars17 lines
In this example, we first generate some example data for "index" and "price1". We then use the "polyfit" function to fit a 4th degree polynomial curve to the data. The resulting polynomial coefficients are stored in the "p" vector. We then use the "polyval" function to evaluate the polynomial at a range of new "x" values, and store the resulting "y" values in the "y" vector. Finally, we plot both the original data and the fitted polynomial curve using the "plot" function.
Note that the degree of the polynomial you choose should depend on the complexity of your data and how well you want the polynomial to fit. You may need to experiment with different polynomial degrees to find the one that works best for your data.
gistlibby LogSnag