MATLAB: Matlabs polyfit not working correctly problem

polufitpolyvalreal polinomial

Hello,
i have a vector called "mean_vec" which consists of 81 values of " -0.1175 -0.1181 "-0.1175 -0.1194 -0.1197 -0.1195 -0.1205 -0.1214 -0.1215 …etc.."
i made a polyfit to it using T_vec with polifit
p = polyfit(T_vec,mean_vec,3);
vector p (the coefficents of the polinomial) are:
0.0000 -0.0009 0.3100 -33.8948
so i tried to recreate my "mean_vec" using a polinomial
pol=-0.0009.*(T_vec).^2+0.31.*T_vec-33.8948
But i get "pol" to have value atronomickly higher then "mean_vec"
where as if i do polyval(p,T_vec); i get almost the exact vector i had before.
where did i go wrong?
Thanks

Best Answer

Highest order is first in the p vector. So explicitly this would be
pol = p(1)*T_vec.^3 + p(2)*T_vec.^2 + p(3)*T_Vec + p(4)
You might be missing exponents on the numbers you used? Double check the displayed output of the polyfit( ) result. There might be an exponent printed right above the p values.