exponential models
about exponential models
the toolbox provides a one-term and a two-term exponential model as given by
exponentials are often used when the rate of change of a quantity is proportional to the initial amount of the quantity. if the coefficient associated with b and/or d is negative, y represents exponential decay. if the coefficient is positive, y represents exponential growth.
for example, a single radioactive decay mode of a nuclide is described by a one-term exponential. a is interpreted as the initial number of nuclei, b is the decay constant, x is time, and y is the number of remaining nuclei after a specific amount of time passes. if two decay modes exist, then you must use the two-term exponential model. for the second decay mode, you add another exponential term to the model.
examples of exponential growth include contagious diseases for which a cure is unavailable, and biological populations whose growth is uninhibited by predation, environmental factors, and so on.
fit exponential models interactively
open the curve fitter app by entering
curvefitter
at the matlab® command line. alternatively, on the apps tab, in the math, statistics and optimization group, click curve fitter.in the curve fitter app, select curve data. on the curve fitter tab, in the data section, click select data. in the select fitting data dialog box, select x data and y data, or just y data against an index.
click the arrow in the fit type section to open the gallery, and click exponential in the regression models group.
the fit options pane for the single-term exponential fit is shown here.
you can specify the following options in the fit options pane:
choose one or two terms to fit
exp1
orexp2
. look in the results pane to see the model terms, values of the coefficients, and goodness-of-fit statistics.optionally, in the advanced options section, specify coefficient starting values and constraint bounds appropriate for your data, or change algorithm settings. the coefficient starting values and constraints shown here are for the
census
data.the app calculates optimized start points for exponential fits, based on the data set. you can override the start points and specify your own values in the fit options pane. for an example specifying starting values appropriate to the data, see .
for more information on the settings, see .
fit exponential models using the fit function
this example shows how to fit an exponential model to data using the fit
function.
the exponential library model is an input argument to the fit
and fittype
functions. specify the model type 'exp1'
or 'exp2'
.
fit a single-term exponential model
generate data with an exponential trend and then fit the data using a single-term exponential. plot the fit and data.
x = (0:0.2:5)';
y = 2*exp(-0.2*x) 0.1*randn(size(x));
f = fit(x,y,'exp1')
f = general model exp1: f(x) = a*exp(b*x) coefficients (with 95% confidence bounds): a = 2.021 (1.89, 2.151) b = -0.1812 (-0.2104, -0.152)
plot(f,x,y)
fit a two-term exponential model
f2 = fit(x,y,'exp2')
f2 = general model exp2: f2(x) = a*exp(b*x) c*exp(d*x) coefficients (with 95% confidence bounds): a = 384.8 (-4.78e 09, 4.78e 09) b = -0.2572 (-2939, 2938) c = -382.8 (-4.78e 09, 4.78e 09) d = -0.2577 (-2957, 2957)
plot(f2,x,y)
set start points
the toolbox calculates optimized start points for exponential fits based on the current data set. you can override the start points and specify your own values.
find the order of the entries for coefficients in the first model ( f
) by using the coeffnames
function.
coeffnames(f)
ans = 2x1 cell
{'a'}
{'b'}
if you specify start points, choose values appropriate to your data. set arbitrary start points for coefficients a
and b
for example purposes.
f = fit(x,y,'exp1','startpoint',[1,2])
f = general model exp1: f(x) = a*exp(b*x) coefficients (with 95% confidence bounds): a = 2.021 (1.89, 2.151) b = -0.1812 (-0.2104, -0.152)
plot(f,x,y)
examine exponential fit options
examine the fit options if you want to modify fit options such as coefficient starting values and constraint bounds appropriate for your data, or change algorithm settings. for details on these options, see the table of properties for nonlinearleastsquares on the fitoptions
reference page.
fitoptions('exp1')
ans = nlsqoptions with properties: startpoint: [] lower: [] upper: [] algorithm: 'trust-region' diffminchange: 1.0000e-08 diffmaxchange: 0.1000 display: 'notify' maxfunevals: 600 maxiter: 400 tolfun: 1.0000e-06 tolx: 1.0000e-06 robust: 'off' normalize: 'off' exclude: [] weights: [] method: 'nonlinearleastsquares'
see also
apps
functions
fit
| |