Package: dsp
Autocorrelation sequence
The Autocorrelator
object returns the autocorrelation
sequence for a discretetime, deterministic input, or the autocorrelation
sequence estimate for a discretetime, widesense stationary (WSS)
random process at positive lags.
To obtain the autocorrelation sequence:
Define and set up your autocorrelator. See Construction.
Call step
to compute the autocorrelation
sequence according to the properties of dsp.Autocorrelator
.
The behavior of step
is specific to each object in
the toolbox.
H = dsp.Autocorrelator
returns
an autocorrelator, H
, that computes the autocorrelation
along the first dimension of an ND array. By default, the autocorrelator
computes the autocorrelation at lags from zero to N
– 1, where N is the length of the input
vector or the row dimension of the input matrix. Inputting a row vector
results in a row of zerolag autocorrelation sequence values, one
for each column of the row vector. The default autocorrelator returns
the unscaled autocorrelation and performs the computation in the time
domain.
H = dsp.Autocorrelator('
returns an autocorrelator, PropertyName
',PropertyValue
,
...)H
, with
each property set to the specified value.

Source of maximum lag Specify how to determine the range of lags for the autocorrelation
as 

Maximum positive lag Specify the maximum lag as a positive integer. This property
applies only when the 

Autocorrelation function scaling Specify the scaling to apply to the output as The The Use the 

Domain for computing autocorrelations Specify the domain for computing autocorrelations as 
clone  Create autocorrelator object with same property values 
getNumInputs  Number of expected inputs to step method 
getNumOutputs  Number of outputs of step method 
isLocked  Locked status for input attributes and nontunable properties 
release  Allow property value and input characteristics changes 
step  Autocorrelation sequence 
The autocorrelation of a deterministic discretetime sequence, x(n) is:
$${r}_{x}(h)={\displaystyle \sum _{n=0}^{Nh1}{x}^{*}}(n)x(n+h)\text{\hspace{1em}}h=0,1,\dots ,N1$$
where h is the lag and * denotes the complex conjugate. If the input is a length N realization of a WSS stationary random process, r_{x}(h) is an estimate of the theoretical autocorrelation:
$${\rho}_{x}(h)=E\{{x}^{*}(n)x(n+h)\}$$
where E{
} is the expectation operator. The Unity at zerolag
normalization divides
each sequence value by the autocorrelation or autocorrelation estimate
at zero lag.
$$\frac{{\rho}_{x}(h)}{{\rho}_{x}(0)}=\frac{E\{{x}^{*}(n)x(n+h)\}}{E\left\{\rightx(0){}^{2}\}}$$
The most commonly used estimate of the theoretical autocorrelation of a WSS random process is the biased estimate:
$${\widehat{\rho}}_{x}(h)=\frac{1}{N}{\displaystyle \sum _{k=0}^{Nh1}{x}^{*}}(n)x(n+h)$$
Compute autocorrelation for all positive lags:
hac1 = dsp.Autocorrelator; % x is a column vector x = [1:100]'; y = step(hac1, x);
Compute the autocorrelation of a sine wave in white Gaussian noise with approximate 95% upper and lower confidence limits:
S = rng('default'); % Sine wave with period N=4 x = 1.4*cos(pi/2*(1:100))'+randn(100,1); MaxLag = 20; H = dsp.Autocorrelator('MaximumLagSource',... 'Property','MaximumLag',MaxLag,'Scaling','Unity at zerolag'); SigAutocorr = step(H,x); stem(SigAutocorr,'b','markerfacecolor',[0 0 1]); line(1:MaxLag+1,1.96/sqrt(100)*ones(MaxLag+1,1),... 'linestyle','.','linewidth',2); line(1:MaxLag+1,1.96/sqrt(100)*ones(MaxLag+1,1),... 'linestyle','.','linewidth',2); axis([1 20 1 1]); title('Sine Wave + Noise Autocorrelation'); xlabel('Lag');
As this figure shows, the autocorrelation estimate demonstrates the four sample periodic sine wave with excursions outside the 95% white Gaussian noise confidence limits every two samples.
This object implements the algorithm, inputs, and outputs described on the Autocorrelation block reference page. The object properties correspond to the block parameters.