LabWindows/CVI

Table of Contents
  • LabWindows/CVI Fundamentals
  • Creating Applications
  • Distributing Applications
  • Library Reference
  • Programmer Reference
  • Hardware Information

CxAutoCorrelate

Advanced Analysis Library Only

AnalysisLibErrType CxAutoCorrelate (NIComplexNumber inputArray[], ssize_t sizeOfInputArray, int norm, NIComplexNumber outputArray[]);

Purpose

Finds the autocorrelation of the complex input array. The autocorrelation Rxx(t) of a function x(t) is defined as the following:

where the symbol denotes correlation.

For the discrete implementation of this function, let Y represent a sequence whose indexing can be negative, let N be the number of elements in the input sequence inputArray, and assume that the indexed elements of inputArray that lie outside its range are equal to zero, as shown in the following relationship:

xj = 0 , j < 0 or jN

Then CxAutoCorrelate obtains the elements of Y using the following equation:

for j = -(N–1), -(N–2), ..., -1, 0, 1, ..., (N–2), (N–1)

The elements of the output sequence outputArray are related to the elements in the sequence Y by

Rxxi = yi-(N–1)

for i = 0, 1, 2, ..., 2N–2

Notice that the number of elements in the output sequence outputArray is 2N–1. Because you cannot use negative numbers to index LabWindows/CVI arrays, the corresponding correlation value at t = 0 is the Nth element of the output sequence outputArray. Therefore, outputArray represents the correlation values that CxAutoCorrelate shifts N times in indexing.

In order to make the autocorrelation calculation more accurate, normalization is required in some situations. This function provides biased and unbiased normalization.

  • Biased normalization

    If norm is ALGORITHM_CONCOR_BIASED_NORMALIZATION, LabWindows/CVI applies biased normalization as follows:

    for j = -(N–1), -(N–2), ..., -1, 0, 1, ..., (N–2), (N–1), and

    Rxx(biased) = yi-(N–1)

    for i = 0, 1, 2, ..., 2N–2

  • Unbiased normalization

    If norm is ALGORITHM_CONCOR_UNBIASED_NORMALIZATION, LabWindows/CVI applies unbiased normalization as follows:

    for j = -(N–1), -(N–2), ..., -1, 0, 1, ..., (N–2), (N–1), and

    Rxx(unbiased) = yi-(N–1)

    for i = 0, 1, 2, ..., 2N–2

Note Note  This function temporarily allocates memory for use as a work area. If CxAutoCorrelate cannot allocate memory, the function returns an error code.

Example Code

/* Generate one array with random numbers and find its autocorrelation. */
NIComplexNumber x[256];
NIComplexNumber rxx[512];
double input[256];
int i;
int n;
n = 256;
WhiteNoise (n, 1, 17, input);
for(i = 0; i < n; i++)
{

x[i].real = input[i];
x[i].imaginary = input[i];

}
CxAutoCorrelate (x, n, ALGORITHM_CORCOR_NO_NORMALIZATION, rxx);

Parameters

Input
Name Type Description
inputArray NIComplexNumber [] The input array for which to compute the autocorrelation operation.
sizeOfInputArray ssize_t Number of elements in inputArray.
norm int Specifies the normalization method to use to compute the autocorrelation of inputArray. normalization must be one of the following values:

Constant Value Description
ALGORITHM_CORCOR_NO_NORMALIZATION 0 No normalization is used in the autocorrelation computation.
ALGORITHM_CONCOR_UNBIASED_NORMALIZATION 1 Use sizeOfInputArray to normalize the correlation result.
ALGORITHM_CONCOR_BIASED_NORMALIZATION 2 Use the number of elements in inputArray for computing Rxx[j] to normalize Rxx[j], j = 0, 1, ..., (2n-2).
Output
Name Type Description
outputArray NIComplexNumber [] The autocorrelation of inputArray. This array must be at least (2n – 1) elements long.

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

Log in to get a better experience