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 Center および File ExchangeCode Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by