Integrate
Advanced Analysis Library Only
AnalysisLibErrType Integrate (double inputArray[], ssize_t numberOfElements, double samplingInterval, double initialCondition, double finalCondition, double outputArray[]);
Purpose
Calculates the discrete integral of the input array Simpson's Rule for discrete evaluation. Integrate obtains the element of the resulting array using the following formula:

where | X–1 is the initial condition |
Xn is the final condition | |
i is the array index | |
n is the number of elements | |
dt is the sampling interval |
The values are accumulated into the output array. Thus, the last element of the array contains the area under the curve.
Integrate can perform the operation in place; that is, the input and output arrays can be the same.
Example
/* Generate an array with random numbers and integrate it. */
double x[200], y[200];
double dt, xInit, xFinal;
int n;
n = 200;
dt = 0.001;
xInit = -0.5;
xFinal = -0.25;
Uniform (n, 17, x);
Integrate (x, n, dt, xInit, xFinal, y);
Parameters
Input | ||
Name | Type | Description |
inputArray | double [] | Input array to integrate. |
numberOfElements | ssize_t | Number of elements used to compute the integral value of the input array. |
samplingInterval | double | Sampling interval used in the integration. Default Value: 1.0. |
initialCondition | double | Initial condition. When the integration formula is applied to each array element, the value of the preceding array element is used. initialCondition specifies the value preceding the first element of the input array. In other words, initialCondition can be thought of as the value of X–1. Default Value: 0.0. |
finalCondition | double | Final condition. When the integration formula is applied to each array element, the value of the next array element is used. finalCondition specifies the value following the last element of the input array. In other words, finalCondition can be thought of as the value of Xn. Default Value: 0.0. |
Output | ||
Name | Type | Description |
outputArray | double [] | Integrated array. |
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