LabWindows/CVI

Content Type
Programming Language
Current manual

ExpFit

Advanced Analysis Library Only

AnalysisLibErrType ExpFit (double arrayX[], double arrayY[], ssize_t numberOfElements, double outputArray[], double *amplitude, double *decay, double *meanSquaredError);

Purpose

Note Note  This function has been superseded by ExpFitEx.

Finds the coefficient values that best represent the exponential fit of the data points (X, Y) using the least squares method. ExpFit obtains the ith element of the output array using the following formula:

Zi = aedXi

where a = amplitude
d = decay
i = array index

ExpFit obtains the mean squared error using the following formula:

where numberOfElements is the number of sample points.

ExpFit can perform this operation in place; that is, the input and output arrays can be the same.

Example Code

/* Generate an exponential pattern and find the best exponential fit. */
double x[200], y[200], z[200];
double first, last, a, b, amp, decay, mse;
n;
n = 200;
first = 0.0;
last = 1.99E2;
Ramp (n, first, last, x); /* x[i] = i */
a = 3.5;
b = -2.75;
for (i=0; i<n; i++)

y[i] = a * exp(b*x[i]);

/* Find the best exponential fit in z. */
ExpFit (x, y, n, z, &amp, &decay, &mse);

Note    The y values must be all positive or all negative to perform an exponential fit.

Parameters

Input
Name Type Description
arrayX double [] An array whose elements contain the X coordinates of the (X,Y) data sets.
arrayY double [] An array whose elements contain the Y coordinates of the (X,Y) data sets.
numberOfElements ssize_t Number of sample points used in the exponential fit operation.
Output
Name Type Description
outputArray double [] Best exponential fit.
amplitude double Value that best describes the amplitude of the exponential curve.
decay double Decay value that best describes the exponential curve.
meanSquaredError double The mean squared error generated by the difference between the fitted curve and the raw data.

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.

Additional Information

Library: Advanced Analysis Library

Include file: analysis.h

LabWindows/CVI compatibility: LabWindows/CVI 3.1 and later

Was this information helpful?

Previous

LinFit

Previous

LinFit

Log in to get a better experience

Tariff Impact Update Learn more

Help us improve your future ni.com experience.

Did you find the documentation you were looking for?

Submit