matlabs polyfit not working correctly problem

조회 수: 1 (최근 30일)
fima v
fima v 2020년 4월 7일
편집: James Tursa 2020년 4월 7일
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