This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

dsp.Crosscorrelator System object

Cross-correlation of two inputs


The Crosscorrelator returns the cross-correlation sequence for two discrete-time deterministic inputs. This object can also return the cross-correlation sequence estimate for two discrete-time, jointly wide-sense stationary (WSS), random processes.

To obtain the cross-correlation for two discrete-time deterministic inputs:

  1. Define and set up your cross-correlator. See Construction.

  2. Call step to compute the cross-correlation according to the properties of dsp.Crosscorrelator. The behavior of step is specific to each object in the toolbox.


Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


xcorr = dsp.Crosscorrelator returns a cross-correlator object, xcorr, that computes the cross-correlation of two inputs. For N-D arrays, the cross-correlator computes the correlation column-wise. The inputs must have an equal number of columns. If one input is a vector and the other is an N-D array, the cross-correlator computes the cross-correlation of the vector with each column of the N-D array. Cross correlating inputs of length N and M results in a cross-correlation sequence of length N+M–1. Cross correlating matrices of size M-by-N and P-by-N results in a matrix of cross-correlation sequences of size M+P–1-by-N.

xcorr = dsp.Crosscorrelator('PropertyName',PropertyValue, ...) returns a cross-correlator, xcorr, with each property set to the specified value.



Domain for computing correlations

Specify the domain for computing correlation as Time Domain, Frequency Domain, or Fastest. Computing correlations in the time domain minimizes memory use. Computing correlations in the frequency domain may require fewer computations than computing in the time domain depending on the input length. If the value of this property is Fastest, the cross-correlator operates in the domain which minimizes the number of computations. The default is Time Domain.

 Fixed-Point Properties


stepCross-correlation sequence
Common to All System Objects

Create System object with same property values


Expected number of inputs to a System object


Expected number of outputs of a System object


Check locked states of a System object (logical)


Allow System object property value changes


expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

xcorr = dsp.Crosscorrelator;
t = 0:0.001:1;
x1 = sin(2*pi*2*t)+0.05*sin(2*pi*50*t);
x2 = sin(2*pi*2*t);
y = xcorr(x1,x2); %computes cross-correlation of x1 and x2
figure,plot(t,x1,'b',t, x2, 'g');
legend('Input signal 1',' Input signal 2')

figure, plot(y); title('Correlated output')

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

Use cross-correlation to detect delay in jointly stationary white Gaussian noise inputs.

S = rng('default');

white Gaussian noise input

x = randn(100,1);

Create copy delayed by 10 samples x1[n] = x[n-10]

delay = dsp.Delay(10);
x1 = delay(x);
xcorr = dsp.Crosscorrelator;
y = xcorr(x1,x);
lags = 0:99; %Positive lags
stem(lags,y(100:end),'markerfacecolor',[0 0 1]);
axis([0 99 -125 125]);
title('Cross-Correlation of Input Noise and Delayed Version');

The theoretical cross-correlation sequence is identically zero except at lag 10. Note this is not true in the sample cross-correlation sequence, but the estimate demonstrates a peak at the correct lag.


expand all


expand all

Extended Capabilities

Introduced in R2012a

Was this topic helpful?