multi Exponential regression method
8 views (last 30 days)
Show older comments
I work regression about a number of data. so I use matlab fuction : fit(x,y,exp2) but, I wonder that How do get a, b, c, d of f(x)=a*exp(bx)+c*exp(dx).
0 Comments
Answers (2)
Torsten
on 7 Apr 2017
If you use
f=fit(x,y,exp2)
f is automatically shown after execution.
Best wishes
Torsten.
0 Comments
John D'Errico
on 7 Apr 2017
Edited: John D'Errico
on 7 Apr 2017
For example:
mdl = fit(rand(100,1),rand(100,1),'exp2')
mdl =
General model Exp2:
mdl(x) = a*exp(b*x) + c*exp(d*x)
Coefficients (with 95% confidence bounds):
a = -1101 (-9.55e+11, 9.55e+11)
b = 0.9633 (-1.213e+05, 1.213e+05)
c = 1102 (-9.55e+11, 9.55e+11)
d = 0.963 (-1.213e+05, 1.213e+05)
The coefficients themselves in this case are total garbage, because my data was just random numbers. The massively wide confidence bounds reflect that fact.
Regardless, you can see the values there. But they are printed only to a few significant digits. NEVER just take those numbers as is and try to use them. You need the full values of the coefficients, if you will use them. So, how do you extract the values themselves as numbers?
When you have no idea what applies to a class, then look at methods. It will tell you. First, we can see that mdl is an object of class cfit.
whos mdl
Name Size Bytes Class Attributes
mdl 1x1 1198 cfit
What methods apply to that class?
methods(mdl)
Methods for class cfit:
argnames coeffnames dependnames fitoptions integrate numcoeffs probnames type
category coeffvalues differentiate formula islinear plot probvalues
cfit confint feval indepnames numargs predint setoptions
So, clearly coeffvalues will be of use here. If you are not sure, then use the help:
help cfit/coeffvalues
coeffvalues Coefficient values.
coeffvalues(FUN) returns the values of the coefficients of the
CFIT object FUN as a row vector.
See also cfit/probvalues, fittype/formula.
YEP. coeffvalues is what you need.
format long g
coeffvalues(mdl)
ans =
-1101.27586379757 0.963250512625987 1101.7626267532 0.96297061650439
When you have a problem, the help is there to serve your needs. Use it.
0 Comments
See Also
Categories
Find more on Fit Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!