MATLAB: Does the fitted polynomial not match with original data

Curve Fitting Toolbox

I used the CFTool to create a degree-4 polynomial fit with robust parameter set to 'bisquare'. I then manually put the generated coefficients in a separate array P as shown in the attached script 'manually_extracted_coefficients'. However, when I plotted the polynomial with these coefficients, it was nowhere near the original data. 
To reproduce this issue, run the attached 'manually_extracted_coefficients.m'

Best Answer

The error is probably due to the fact that the polynomial evaluation is very sensitive to even very small changes in the coefficient values.
For example, lets say P1 is the set of hand-copied coefficients that you generated and P2 is the set I generated. The only difference being how many digits were copied from the Curve Fitting Tool analysis. Even the polynomials generated from these two sets of coefficients are very different. However, the ratio of corresponding coefficients in P1 and P2 is very close to 1. 
The generated polynomials are very very sensitive to even the relatively small change in coefficient values. So the best way moving forward would be to extract coefficients programmatically from the model generated by Curve Fitting Tool. There are two ways to go about this,
1. You can export the fitted model to MATLAB workspace by navigating to Fit > Save to workspace and selecting 'Save fit to MATLAB object named' option.
2. You can also generate a MATLAB function to perform the same fit on other datasets. For this, you can go to File > Generate Code. This will generate a function similar to the attached 'createFit.m'.
I have demonstrated all this analysis in the attached 'CFDemo.m'.