Inf computed by model function, fitting cannot continue.

14 次查看(过去 30 天)
I have the following data:
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] and y = [1, -0.2213, 0.4189, 0.2125, -0.542, 0, 0, 0, 0, 0]
I'm trying to fit an exponetial curve and even though it is not the best curve to fit, I need it to be exponential. The thing is that it has worked for every single of the other vectors that i have (even for the ones with all-negative values and much worse data) but for some reason the fitting function gives me this error only for this one:
Error using fit>iFit (line 348)
Inf computed by model function, fitting cannot continue.
Try using or tightening upper and lower bounds on coefficients.
Error in fit (line 116)
[fitobj, goodness, output, convmsg] = iFit( xdatain, ydatain, fittypeobj, ...
This is my code:
f = fittype('exp(-x/phi)', 'independent', 'x');
myfit_uu2 = fit(x', y', f, 'StartPoint', 1);
lambda = myfit_uu2.phi;

回答(1 个)

Harsha Priya Daggubati
Hi,
I tried replicating running your code in MATLAB R2019b. I got the result with lamda as 0.0294. No issues as you mentioned.
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
y = [1, -0.2213, 0.4189, 0.2125, -0.542, 0, 0, 0, 0, 0];
f = fittype('exp(-x/phi)', 'independent', 'x');
myfit_uu2 = fit(x', y', f, 'StartPoint', 1);
lambda = myfit_uu2.phi;
Can you try restarting your MATLAB and using these commands:
rehash toolbox
rehash toolboxcache
Or else try updating to the newer MATLAB versions.
Hope this helps!
  1 个评论
Ivy Gao
Ivy Gao 2020-8-7
Hi, does this code work on your MATLAB?
baffledTB_x = [0
1.25
2.5
3
3.5
4
18.5];
baffledTB_y = [0.06
0.155
0.289
0.412
0.576
0.641
1.76];
x = baffledTB_x;
y = baffledTB_y;
myfittype = fittype('a + b*log(x)',...
'dependent',{'y'},'independent',{'x'},...
'coefficients',{'a','b'})
myfit=fit(x,y,myfittype,'StartPoint',[0 0.6])
Thanks!!!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by