Use of function polyval, MATLAB in Statistics

Use of function polyval:

The better the curve fit, the more exact these interpolated and extrapolated values will be. By using the subplot function, we can loop to display the difference between fitting curves of degrees 1, 2, and 3 to some data. For illustration the script below will accomplish this for the temperature data: