MATLAB: How can I use a*exp(bx)+ cx+d to fit the curve instead of two term exponential

Curve Fitting Toolboxfit the data with one term exponential and second term linear

Hi there I'm trying to fit the data with one term exponential and second term linear instead of using two term exponential. Although the curve fitting tool does allow me to do this, just not convinced that this is possible without transforming the data. Please can anyone help to clarify this query?

Best Answer

If you take the subset of the problem in which you have four equations in four unknowns, you can attempt to see if there is a closed form solution.
If you do stepwise elimination first eliminating d, then c, then a, then you can solve the remaining equation for b. The general form you get is
b = RootOf(exp(_Z)*x1*y2-exp(_Z)*x1*y3-exp(_Z)*x2*y1+exp(_Z)*x2*y3+exp(_Z)*x3*y1-exp(_Z)*x3*y2-exp(_Z*x1/x4)*x2*y3+exp(_Z*x1/x4)*x2*y4+exp(_Z*x1/x4)*x3*y2-exp(_Z*x1/x4)*x3*y4-exp(_Z*x1/x4)*x4*y2+exp(_Z*x1/x4)*x4*y3+exp(_Z*x2/x4)*x1*y3-exp(_Z*x2/x4)*x1*y4-exp(_Z*x2/x4)*x3*y1+exp(_Z*x2/x4)*x3*y4+exp(_Z*x2/x4)*x4*y1-exp(_Z*x2/x4)*x4*y3-exp(_Z*x3/x4)*x1*y2+exp(_Z*x3/x4)*x1*y4+exp(_Z*x3/x4)*x2*y1-exp(_Z*x3/x4)*x2*y4-exp(_Z*x3/x4)*x4*y1+exp(_Z*x3/x4)*x4*y2)/x4
Here, RootOf(expression in _Z) stands for the set of all values, _Z, such that the expression becomes 0 -- the roots of the equation.
There is no obvious closed form solution for this in the general case. However, once you substitute in particular x1, x2, x3, x4, it might happen to have a closed form solution. For example for x1=1, x2=2, x3=3, x4=4, then b = ln((y2-2*y3+y4)/(y1-2*y2+y3)).
This cannot, however, be easily generalized: for x1=1, x2=2, x3=3, x4=5, then b = ln((-y1+2*y2-y3+sqrt(y1^2-2*y1*y2-y1*y3+y1*y4+4*y2*y3-2*y2*y4-2*y3^2+y3*y4))/(y1-2*y2+y3))
There are an infinite number of additional complex-valued solutions, but it is looking like there is possibly at most one real-valued solution for b... but that would be difficult to prove.
Now, these would be definite solutions for the case with four points, not least squared solutions. This would, though, permit you to estimate starting points, and to cross-check that the values you get from cftool() or fit() are reasonable.
Related Question