Admin Production ni-theme
Current Publication

DifferenceEx

LabWindows/CVI

DifferenceEx

Advanced Analysis Library Only

AnalysisLibErrType DifferenceEx (double inputArray[], ssize_t numberOfElements, double samplingInterval, double initialConditions[], ssize_t initialConditionsSize, double finalConditions[], ssize_t finalConditionsSize, int differenceMethod, double outputArray[]);

Purpose

Differentiates the input signal inputArray using the second order central, fourth order central, forward, or backward differentiation method.

If differenceMethod is SECOND_ORDER_CENTRAL_DIFF, outputArray is given by

for i = 0,1,2,...,n-1 where n is the length of inputArray, x_{-1} is the first element in initialConditions, and x_{n} is the first element in finalConditions.

If differenceMethod is FOURTH_ORDER_CENTRAL_DIFF, outputArray is given by

for i = 0,1,2,...,n-1

where n is the length of inputArray, x_{-2} and x_{-1} are the first and second elements in initialConditions, x_{n} and x_{n+1}are the first and second elements in final condition.

If differenceMethod is FORWARD_DIFF, outputArray is given by

for i = 0,1,2,...,n-1

where n is the length of inputArray, x_{n} is the first element in finalConditions.

If differenceMethod is BACKWARD_DIFF, outputArray is given by:

for i = 0,1,2,...,n-1

where n is the length of inputArray, x_{-1} is the first element of initialConditions.

Parameters

Input
Name Type Description
numberOfElements ssize_t The length of inputArray.
samplingInterval double The sampling interval. samplingInterval must be greater than zero.
initialConditions double [] The initial condition array of inputArray. The function uses the first element in initialConditions to calculate the derivative if differenceMethod is SECOND_ORDER_CENTRAL_DIFF or BACKWARD_DIFF. The function uses the first two elements in initialConditions to calculate the derivative if differenceMethod is FOURTH_ORDER_CENTRAL_DIFF.
initialConditionsSize ssize_t The length of initialConditions. If differenceMethod is SECOND_ORDER_CENTRAL_DIFF or BACKWARD_DIFF, initialConditionsSize must be 1. If differenceMethod is FOURTH_ORDER_CENTRAL_DIFF, initialConditionsSize must be 2.
finalConditions double [] The final condition array of inputArray. The function uses the first element in finalConditions to calculate the derivative if differenceMethod is SECOND_ORDER_CENTRAL_DIFF or FORWARD_DIFF. The function uses the first two elements in finalConditions to calculate the derivative if method is FOURTH_ORDER_CENTRAL_DIFF.
finalConditionsSize ssize_t The length of finalConditions. If differenceMethod is SECOND_ORDER_CENTRAL_DIFF or FORWARD_DIFF, finalConditionsSize must be 1. If differenceMethod is FOURTH_ORDER_CENTRAL_DIFF, finalConditionsSize must be 2.
differenceMethod int The differentiation method. differenceMethod must be one of the following values:
  • SECOND_ORDER_CENTRAL_DIFF (0)
  • FOURTH_ORDER_CENTRAL_DIFF (1)
  • FORWARD_DIFF (2)
  • BACKWARD_DIFF (3)
Output
Name Type Description
inputArray double [] The sampled signal to perform differentiation. If outputArray is NULL, the differentiation result overwrites inputArray.
outputArray double [] The differentiation of inputArray.

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 8.5 and later