cftool and fit function returns different results

3 vues (au cours des 30 derniers jours)
yonatan s
yonatan s le 27 Sep 2018
Modifié(e) : dpb le 27 Sep 2018
I fit data using both methods and am getting different results.
The fitted function is: f(x)=a*x^(b).
The results are:
cftool: a=3.238e+10, b=-1.573.
fit function: a=1.516e+07, b=-1.111.
And of course, the goodness of fit parameters are different.
I set the options in the fit function to be the same as in cftool.
The script:
PowerEqn='a*x^(b)';
fo = fitoptions('Method','NonlinearLeastSquares',...
'Robust','off',...
'Algorithm','Trust-Region',...
'DiffMinChange',1e-8,...
'DiffMaxChange',.1,...
'MaxFunEvals',600,...
'MaxIter',400,...
'TolFun',1e-6,...
'TolX',1e-6,...
'StartPoint',[x(1),y(1)]);
ft=fittype(PowerEqn,'options',fo);
[f,stat]=fit(x',y',ft);
The Data:
x=[1.5804e+07,1.1580e+08,2.1580e+08,3.1580e+08,4.1580e+08,5.1580e+08,6.1580e+08,7.1580e+08,
8.1580e+08,9.1580e+08,1.0158e+09,1.1158e+09,1.2158e+09,1.3158e+09,1.4158e+09];
y=[1.5398e-01,4.7623e-03,6.6259e-03,1.7019e-03,1.4101e-03,0,5.8168e-06,
0,0,0,0,0,0,0,0]
  3 commentaires
yonatan s
yonatan s le 27 Sep 2018
Modifié(e) : yonatan s le 27 Sep 2018
yeah you're right. but in cftool I pressed on FitOptions button (see image) and just entered those results. so what am I missing?
dpb
dpb le 27 Sep 2018
Modifié(e) : dpb le 27 Sep 2018
Your starting points aren't the same as in the cftool window -- if I use the builtin form of the equation I get the default result.
However using the text form for the equation and the [x(1) y(1)] startpoints then I get your same result. So, there's something going on behind the scenes...
>> fit(x',y','power1',fo)
ans =
General model Power1:
ans(x) = a*x^b
Coefficients (with 95% confidence bounds):
a = 3.231e+10 (-6.071e+10, 1.253e+11)
b = -1.573 (-1.746, -1.399)
>> fo.StartPoint=[x(1) y(1)];
>> fit(x',y','power1',fo)
ans =
General model Power1:
ans(x) = a*x^b
Coefficients (with 95% confidence bounds):
a = 3.276e+10 (-6.174e+10, 1.273e+11)
b = -1.574 (-1.748, -1.4)
>> eqn='a*x^b';
>> fit(x',y',eqn,fo)
ans =
General model:
ans(x) = a*x^b
Coefficients (with 95% confidence bounds):
a = 1.58e+07 (-2.917e+07, 6.077e+07)
b = -1.114 (-1.285, -0.9424)
>> fo.StartPoint=[8.2638E11 -1.7388];
>> fit(x',y',eqn,fo)
ans =
General model:
ans(x) = a*x^b
Coefficients (with 95% confidence bounds):
a = 8.264e+11 (-3.335e+12, 4.988e+12)
b = -1.768 (-2.072, -1.464)
>>
What, specifically, I've no klew

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by