Admin Production ni-theme
Current Publication

Difference

LabWindows/CVI

Difference

Advanced Analysis Library Only

AnalysisLibErrType Difference (double inputArray[], ssize_t numberOfElements, double samplingInterval, double initialCondition, double finalCondition, double outputArray[]);

Purpose

Note Note  This function has been superseded by DifferenceEx.

Finds the discrete difference of the input array. Difference obtains the element of the resulting array using the following formula:

where X–1 is the initial condition
Xn is the final condition

Difference 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 differentiate 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);
Difference (x, n, dt, xInit, xFinal, y);

Parameters

Input
Name Type Description
inputArray double [] Input array to differentiate.
numberOfElements ssize_t Number of elements to include in the differentiation.
samplingInterval double Sampling interval used in the differentiation of the input array.

Default Value: 1.0.
initialCondition double Initial condition.

When the differentiation 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 differentiation 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 [] Differentiated 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