CCF (FPScript)
Calculates the cross-correlation function of two signals. Used to describe the similarity between two signals.
Syntax
CCF(Signal1, Signal2 [ , Mode = CORRELATIONPRODUCT_NONCIRCULAR ])
The syntax of the CCF function consists of the following parts:
Part |
Description |
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Signal1 |
The signal whose correlation with the second signal is calculated. Permitted data structures are data series, data matrix, signal und signal series. All numeric data types are permitted. Void values are not permitted in this argument. For the X component additional restrictions do apply.The values must have a constant positive spacing. For complex data types the absolute value is formed. If the argument is a list, then the function is executed for each element of the list and the result is also a list. |
||||||||||||||
Signal2 |
The signal whose correlation with the first signal is calculated. Permitted data structures are data series, data matrix, signal und signal series. All numeric data types are permitted. Void values are not permitted in this argument. For the X component additional restrictions do apply.The values must have a constant positive spacing. For complex data types the absolute value is formed. If the argument is a list, then the function is executed for each element of the list and the result is also a list. |
||||||||||||||
Mode |
Specifies the calculation mode. The argument Mode can have the following values:
If the argument is a list, then the first element in the list is taken. If this is also a list, then the process is repeated. If this argument is omitted, it will be set to the default value CORRELATIONPRODUCT_NONCIRCULAR. |
Remarks
The result always has the data type 64-bit floating point.
The unit of the result is the same as the product of the units of Signal1 and Signal2. The cross-correlation for two data series s and g is defined as:
with the correlation product:
and N, the number of values in s and g.
The values of the normalized cross-correlation are between -1 and +1. The normalized cross-correlation calculates the quotient between cross-correlation and the square of the RMS value of the input data set.
The calculation occurs in the frequency domain in all cases according to the following formula:
IRFFTn(*FFTn(Signal1) * FFTn(Signal2))
For two-dimensional arguments, the calculation is carried out column by column, and the result is also two-dimensional. If one of the arguments has an X component, this also applies to the result. This component then contains the τ time lag of the cross-correlation function. Note: If the other argument does not have an X component, the same sampling is used for this argument as is used for the argument with the X component.
For circular cross-correlation, the calculation takes place under the assumption that one or more complete periods of the signals to be analyzed are stored in Signal1 and Signal2. In this case, the number of rows of Signal1 and Signal2 must match.
The non-circular cross-correlation is based on the assumption that the signals outside the sections covered by the Signal1 and Signal2 data sets amount to zero. A sufficient number of zeros are therefore appended to the data sets before the transform into the frequency domain. The cross-correlation function is calculated for all τ values for which the function can have a value not equal to zero, i.e., for which there is still an overlap of both signals.
Available in
FlexPro Basic, Professional, Developer Suite
Examples
Dim digital1 = 0#50
digital1[ValuesAboveLevel(Noise(digital1, NOISE_UNIFORM, 0), 0, EVENT_INDEX)] = 1
Dim digital2 = 0#50
digital2[ValuesAboveLevel(Noise(digital2, NOISE_UNIFORM, 0), 0, EVENT_INDEX)] = 1
Dim d1 = 0#7 : digital1[0,-8]
Dim d2 = 0#11 : digital2[0,-12]
GlobalMaximum(CCF(digital1, d1 + d2, CORRELATIONPRODUCT_CIRCULAR)) // = 7
GlobalMaximum(CCF(digital2, d1 + d2, CORRELATIONPRODUCT_CIRCULAR)) // = 11
This example demonstrates how the time lag between a transmitted and a received signal can be determined using the CCF function. The received signal is the sum of two digital signals with different time lags. The position at which the circular cross-correlation product between the transmitted and received signal has its maximum corresponds to the time lag of the transmitted signal.
See Also
References
[1] "Oppenheim, A. V. and Schafer, R. W.": "Discrete-Time Signal Processing, 2nd Edition", page 743 - 48. "Prentice Hall, New Jersey",1999.ISBN 0-13-754920-2.
[2] "H. D. Lüke": "Signalübertragung (Signal Transmission)", page 79 - 81. "Springer-Verlag Berlin, Heidelberg, New York",1985.ISBN 3-540-15526-0.