matlabs polyfit not working correctly problem

1 次查看(过去 30 天)
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

采纳的回答

James Tursa
James Tursa 2020-4-7
编辑:James Tursa 2020-4-7
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Code Generation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by