Cross Correlation

Computes the cross correlation of two signals.

1378

Inputs/Outputs

datatype_icon

reset

A Boolean that specifies whether to reset the internal state of the node.

True Resets the internal state of the node.
False Does not reset the internal state of the node.

This input is available when either of the input sequences is a double-precision, floating-point number.

Default value: False

datatype_icon

x

The input signal.

This input supports the following data types.

  • Waveform
  • 1D array of waveforms
  • Double-precision, floating-point number
  • 1D array of double-precision, floating-point numbers
  • 1D array of complex double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers
datatype_icon

y

The second input signal, which you want to cross correlate with the first input signal.

This input supports the following data types:

  • Waveform
  • 1D array of waveforms
  • Double-precision, floating-point number
  • 1D array of double-precision, floating-point numbers
  • 1D array of complex double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers
datatype_icon

algorithm

The correlation method to use.

This input is available only if both x and y are arrays or waveforms.

If x and y are small, the direct method typically is faster. If x and y are large, the frequency domain method typically is faster. Additionally, slight numerical differences can exist between the two methods.

direct

Computes the cross correlation using the direct method of linear correlation.

frequency domain

Computes the cross correlation using an FFT-based technique.

Default value: frequency domain

datatype_icon

normalization

The normalization method to use to compute the cross correlation between the two input signals.

This input is available only if both x and y are arrays or waveforms.

none

Does not apply normalization.

unbiased

Applies unbiased normalization.

biased

Applies biased normalization.

Default value: none

datatype_icon

sample length x

Length of each set of x-values.

This node computes each set of values separately.

sample length x must be greater than 0.

This input is available only if x is a double-precision, floating-point number.

Default value: 100

datatype_icon

sample length y

Length of each set of y-values.

This node computes each set of values separately.

sample length y must be greater than 0.

This input is available only if y is a double-precision, floating-point number.

Default value: 100

datatype_icon

error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Default value: No error

datatype_icon

use history data

A Boolean that specifies whether to use the data points before the current block to compute the cross-correlation.

True Uses the data points before the current block to compute the cross-correlation.
False Does not use the data points before the current block to compute the cross-correlation.

This input is available only if one of the input sequences is a double-precision, floating-point number.

Default value: True

datatype_icon

Rxy

Cross correlation of the two input signals.

This output can return the following data types:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
  • 1D array of complex double-precision, floating-point numbers
datatype_icon

error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Algorithm for Calculating the Cross Correlation

The cross correlation Rxy(t) of the sequences x(t) and y(t) is defined by the following equation:

R x y ( t ) = x ( t ) y ( t ) = x * ( τ ) y ( t + τ ) d τ R x y ( t ) = x ( t ) y ( t ) = x * ( τ ) y ( t + τ ) d τ

where the symbol

denotes correlation.

h N x M y x y
x j = 0 , j < 0 o r j N x j = 0 , j < 0 o r j N

and

y j = 0 , j < 0 o r j M y j = 0 , j < 0 o r j M

Then this node obtains the elements of h using the following equation:

h j = k = 0 N 1 x k * y j + k h j = k = 0 N 1 x k * y j + k

for

j=(N1),(N2),...,1,0,1,...,(M2),(M1)

The elements of the output sequence Rxy are related to the elements in the sequence h by

R x y i = h i ( N 1 ) R x y i = h i ( N 1 )

for

i=0,1,2,...,N+M2

Because you cannot index arrays with negative numbers, the corresponding cross correlation value at t = 0 is the Nth element of the output sequence Rxy. Therefore, Rxy represents the correlation values that this node shifts N times in indexing.

How This Node Applies Unbiased Normalization

This node applies unbiased normalization as follows:

R x y ( u n b i a s e d ) j = 1 f ( j ) R x y j R x y ( u n b i a s e d ) j = 1 f ( j ) R x y j

for j = 0, 1, 2, ..., M + N - 2

where Rxy is the cross correlation between x and y with no normalization. f(j) is:


1378

How This Node Applies Biased Normalization

This node applies biased normalization as follows:

R x y ( b i a s e d ) j = 1 max ( M , N ) R x y j R x y ( b i a s e d ) j = 1 max ( M , N ) R x y j

for j = 0, 1, 2, ..., M + N - 2

where Rxy is the cross correlation between x and y with no normalization.