MATLAB: Given equation for polynomial fit does not match curve shown in plot

equationsplotspolynomial fittime series

Hello All.
I am trying to find a curve to fit a time series data set (time in years on x axis v depth in meters on y axis). When I plot my data and use the basic fitting tools to fit a 6th order polynomial to my data the fit is beautiful [magical really!] but I run into an issue when I ask Matlab for the equation. It prints the supposed equation on the plot, but when I go into excel and try to check the curve (ie calculate the depth using the provided 6th order polynomial function) it looks nothing like my data and doesn't fit beautifully like it does in Matlab.
Is it possible that the program is spitting out the wrong equation for the curve it fit to my data? Is there another way to get the equation for the line that the program is showing running through the data so nicely?
For what it's worth, I am using version R2008b.
Thanks for your help!
Raw data:
x= [ 150 380 400 430 550 720 730 760 760 780 790 790 790 830 840 840 850 860 860 870 890 960 990 1000 1020 1100 1120 1340 1360 1360 1490 3180 3340 3560 3780 4000 4170 4220 4350 4690 4870 5030 5120 5180 5340 5510 5570 5620 5650 5830 6270 6370 6400 6580 6590 6730 6820 6840 7080 7080 7390 7460 7590 7740 7840 7900 8100 8230 8240 8350 8400 8420 8100 ]
y= [ -0.23 -0.425 -0.5375 -0.4475 -0.4775 -0.4275 -0.6175 -0.7175 -0.4975 -0.51 -0.685 -0.5375 -0.6175 -0.6375 -0.5775 -0.5575 -0.7475 -0.695 -0.6425 -0.6275 -0.4575 -0.7575 -0.765 -0.8375 -0.645 -0.9275 -0.7075 -0.9875 -1.0075 -0.9475 -1.11 -2.04 -2.3425 -2.4125 -2.9 -2.59 -2.88 -3.0525 -3.31 -3.5 -3.79 -3.815 -3.7425 -4.0625 -3.8925 -4.43 -4.3625 -4.64 -5.1 -4.8925 -5.3325 -5.8025 -5.64 -6.68 -6.0925 -6.27 -6.37 -6.6525 -6.785 -7.5725 -8.3925 -9.245 -9.5925 -10.11 -11.435 -10.3325 -13.1575 -14.535 -14.155 -14.405 -16.145 -15.6175 -11.725 ]
6th degree polynomial function Matlab provides (that doesn't work in reverse):
y = – 7.3e-022*x^{6} + 1.5e-017*x^{5} – 1.2e-013*x^{4} + 4.7e-010*x^{3} – 8.9e-007*x^{2} + 0.00011*x – 0.32

Best Answer

My guess here is that MATLAB probably only supplies a couple significant figures in the interface, but those are actually each calculated to about 15 figures, which are needed for the precise fit you see in the GUI.