Exp Fit Error: Inf computed by model function, fitting cannot continue. Try using or tightening upper and lower bounds on coefficients.

I have successfully fit multiple similar sets with no problem but the attached data gives the error in the title. I tried fitting both first and second order exponentials but they both fail. If anyone can tell me what to do to resolve this I would greatly appreciate it.

 采纳的回答

You need to look at your data. THINK about what is happening. Don't just throw a modeling tool at it and expect magic to always work.
[min(x),max(x)]
ans =
1.3776 1.3811
So your data is over a TINY range. But exponentials tend to have problems with huge numbers. So you also need to be VERY careful as to the multiplier of x in there.
min(y)
ans =
-6.4096
If you plot log(y - 6.45), as a function of x, except for some crap down at the bottom, the fit is pretty good. So a simple exponential model will do pretty well, IF you are careful.
polyfit(x,log(y + 6.45),1)
ans =
-1514.5 2091.1
This tells us that a model something like this is a good idea.
y = a + b*exp(-c*(x-1.38))
where a good starting value for c is approximately 1500.
I've subtracted 1.38 off, since exp(-1500*1.38) will fail in double precision. This is surely why you are having problems. Well, it does not fail. But it underflows. You get a pure zero as a result.
exp(-1500*1.38)
ans =
0
So you very much need to shift the problem. If you do that, and then use 1500 as a starting value for the multiplier, you can get a model of
y = -4.208 + 2.0602*exp(-1670.7*(x-1.38))
This fits your data fairly well.
plot(x,y,'o',x,-4.208 + 2.0602*exp(-1670.7*(x-1.38)),'b-')
So, hey, you don't need to do these things. But if you want to find a valid model that fits your data, it is a good idea. Otherwise, garbage will result.

2 个评论

Thank you so much for your reply John D'Errico. Sadly I don't know much about curve fitting.
Mostly I wanted to create a smooth curve to help define the widths of hundreds of impulse response peaks inside a code.
Can you explain the logic behind how you are deriving your inferences like 1500 is a good starting point for c?

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心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!

Translated by