Inf computed by model function, fitting cannot continue.
조회 수: 13 (최근 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;
댓글 수: 0
답변 (1개)
Harsha Priya Daggubati
2020년 3월 17일
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
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 Center 및 File 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!