How to solve exponential equations.
8 次查看(过去 30 天)
显示 更早的评论
Hello, I have 70 data points in (X and Y) with four unknowns a, b, c, d. I have one exponential equation as y = a*[1-exp(-b*x)] + c*[exp(d*x)-1]. How to find all four unknowns that satisfy all 70 equations?
2 个评论
Nidhi
2021-8-7
@Onkar Khadke Hi Onkar. I am trying to solve a similar problem and I am unable to understand how we can guess the initial parameters to find the unknown constants. Were you able to understand it. If yes, can you please help me understand.
Thanks in advance!
Image Analyst
2021-8-7
编辑:Image Analyst
2021-8-7
@NDC, usually you can plot the data and just manually take a guess. Like pick some formula and try some values and see what gets you in the ballpark. Then use those as initial guesses and let fitnlm() get them more accurate. I'm attaching exponential decay and growth demos.
Start your own question and attach your data if you still need more help. Also say if you have other data if it looks roughly similar or wildly different.
回答(2 个)
John D'Errico
2020-9-10
编辑:John D'Errico
2020-9-10
Thank you for posting this as a question instead of an answer.
The simplest way to solve this is if you have the curve fitting toolbox. (If you do curve fitting often, then any of the curve fitting toolbox, the optimization toolbox or the stats toolbox will all be tremendously useful, and can all solve the problem. The CFTB is perhaps the solution I would tend to gravitate to here, because of the ease of use and nice way the results are presented.)
I don't have your data, so I cannot show the complete solution as I would want. But this should work:
mdl = fittype('a*(1-exp(-b*x)) + c*(exp(d*x)-1)','indep','x')
mdl =
General model:
mdl(a,b,c,d,x) = a*(1-exp(-b*x)) + c*(exp(d*x)-1)
fittedmdl = fit(X(:),Y(:),mdl,'start',abcdstart)
In this, you will need to provide a vector of length 4 (abcdstart) with starting values for the parameters [a,b,c,d]. If you do not do so, then expect possibly random garbage for a result.
By the way, note my use of parens in the model line, where you used square brackets. While what you wrote would work, it is also a good way to cause potential problems, because square brackets are used to concatenate data in MATLAB.
I'm sorry that I cannot help you more, but without seeing your data, I cannot be more complete with my answer. Given your data, I could then be able to recommend viable starting values. The problem with exponential models is they are HIGHLY susceptible to problems in the fits, depending on the data. You will often need to provide at least semi-intelligent starting values. The random start point supplied by fit as a default is often inadequate for such models.
0 个评论
Ameer Hamza
2020-9-10
编辑:Ameer Hamza
2020-9-10
If you don't have curve fitting toolbox, then alternatives from the optimization toolbox are
For example
f = @(p, x) p(1)*(1-exp(-p(2)*x)) + p(3)*(exp(p(4)*x)-1);
xdata = % [70x1] vector of x values
ydata = % [70x1] vector of y values
sol = lsqcurvefit(f, rand(1,4), xdata, y);
a = sol(1);
b = sol(2);
c = sol(3);
d = sol(4);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Least Squares 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!