Get the curve parameters in the fit function

7 次查看(过去 30 天)
How to get the p1 and p2 values after using the fit function. i.e.
[curvepar, fitpar]=fit(rand(100,1), rand(100,1),'poly1')
curvepar =
Linear model Poly1:
curvepar(x) = p1*x + p2
Coefficients (with 95% confidence bounds):
p1 = -0.06171 (-0.2875, 0.1641)
p2 = 0.5492 (0.421, 0.6774)
fitpar =
sse: 9.0309
rsquare: 0.0030
dfe: 98
adjrsquare: -0.0072
rmse: 0.3036
I want the numerical value for p1 and p2? i.e
a=p1; b=p2;
disp(a)

采纳的回答

David Goodmanson
David Goodmanson 2018-2-15
Hi Denise,
follow that command with
p=coeffvalues(curvepar)
The more 'convenient' they make some of these functions, the harder it is to pry information out of them.
  1 个评论
hogr muhammad
hogr muhammad 2022-6-25
Hello dear David Goodmanson,
thank you for your helpful answer, I appreciate your help.
I want to extend your answer to be more precise for dear Denise,
here it is:
p = coeffvalues(curvepar);
a = p(1); % which displays the value of p1
b = p(2); % which displays the value of p2

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Least Squares 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by