MATLAB Answers

How to solve exponential equations.

15 views (last 30 days)
Onkar Khadke
Onkar Khadke on 10 Sep 2020
Edited: Ameer Hamza on 10 Sep 2020
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?

  0 Comments

Sign in to comment.

Answers (2)

John D'Errico
John D'Errico on 10 Sep 2020
Edited: John D'Errico on 10 Sep 2020
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 Comments

Sign in to comment.


Ameer Hamza
Ameer Hamza on 10 Sep 2020
Edited: Ameer Hamza on 10 Sep 2020
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 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!