model for fitting polynomial of degree 3
6 次查看(过去 30 天)
显示 更早的评论
Hi, i want to use 'fitlm' for fitting polynomial of degree 3. Is there some builtin name for the model? For example, for degree 2, matlab used model 'Quadratic'. I tried 'Quartic' but it did not worked.
0 个评论
采纳的回答
John D'Errico
2020-8-20
编辑:John D'Errico
2020-8-20
Just read the help.
x = rand(10,1);
>> y = rand(10,1);
>> D = dataset(x,y);
>> fitlm(D,'poly3')
ans =
Linear regression model:
y ~ 1 + x + x^2 + x^3
Estimated Coefficients:
Estimate SE tStat pValue
__________________ _________________ __________________ __________________
(Intercept) 0.883325330921357 0.269610952016709 3.27629617533717 0.0169006334507573
x -0.905689721171103 2.50947007046528 -0.36090875592837 0.73053441711432
x^2 2.97715513265619 5.78699413259576 0.514456221043511 0.625326610386953
x^3 -2.49404374290891 3.78096082734174 -0.659632261956649 0.53397526842927
Number of observations: 10, Error degrees of freedom: 6
Root Mean Squared Error: 0.182
R-squared: 0.222, Adjusted R-Squared: -0.167
F-statistic vs. constant model: 0.57, p-value = 0.655
I could also have written the model as:
fitlm(D,'y ~ 1 + x + x^2 + x^3')
which produces the same result.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!