dsp.Autocorrelator
(Removed) Autocorrelation sequence
dsp.Autocorrelator
has been removed. Use xcorr
instead.
For more information, see Compatibility Considerations.
Description
The Autocorrelator
object returns the autocorrelation
sequence for a discrete-time, deterministic input, or the autocorrelation sequence estimate
for a discrete-time, wide-sense stationary (WSS) random process at positive lags.
To obtain the autocorrelation sequence:
Create the
dsp.Autocorrelator
object and set its properties.Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
Creation
Description
returns an
autocorrelator, ac
= dsp.Autocorrelatorac
, that computes the autocorrelation along the first
dimension of an N-D 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 zero-lag 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.
returns an autocorrelator, ac
= dsp.Autocorrelator(Name,Value
)ac
, with each property set to the
specified value.
Properties
Unless otherwise indicated, properties are nontunable, which means you cannot change their
values after calling the object. Objects lock when you call them, and the
release
function unlocks them.
If a property is tunable, you can change its value at any time.
For more information on changing property values, see System Design in MATLAB Using System Objects.
MaximumLagSource
— Source of maximum lag
Auto
(default) | Property
Specify how to determine the range of lags for the autocorrelation as
Auto
or Property
. If the value of MaximumLagSource
is Auto
, the
autocorrelator computes the autocorrelation over all nonnegative lags in the interval
[0, N-1]
, where N is the
length of the first dimension of the input. Otherwise, the object computes the
autocorrelation using lags in the range
[0,
.MaximumLag
]
MaximumLag
— Maximum positive lag
1
(default) | 0
| positive integer
Specify the maximum lag as an integer greater than or equal to 0. The MaximumLag
must be less than the length of the input
data.
Dependencies
This property applies only when the MaximumLagSource
property
is Property
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Scaling
— Autocorrelation function scaling
None
(default) | Biased
| Unbiased
| Unity at zero-lag
Specify the scaling to apply to the output as None
,
Biased
, Unbiased
, or Unity at
zero-lag
. Set this property to None
to generate the
autocorrelation function without scaling. This option is appropriate if you are
computing the autocorrelation of a nonrandom (deterministic) input.
The Biased
option scales the autocorrelation by 1/N, where N is the length of the input data. Scaling
by 1/N yields a biased, finite-sample approximation to the theoretical
autocorrelation of a WSS random process. In spite of the bias, scaling by 1/N has the desirable property that the sample autocorrelation matrix is
nonnegative definite, a property possessed by the theoretical autocorrelation matrices
of all wide-sense stationary random processes. The Fourier transform of the biased
autocorrelation estimate is the periodogram, a widely used estimate
of the power spectral density of a WSS process.
The Unbiased
option scales the estimate of the autocorrelation by 1/N – 1. Scaling by N – 1 produces an unbiased estimate of
the theoretical autocorrelation. However, using the unbiased option, you can obtain an
estimate of the autocorrelation function that fails to have the nonnegative definite
property.
Use the Unity at zero-lag
option to normalize the autocorrelation
estimate as identically one at lag zero. The default is None
.
Method
— Domain for computing autocorrelations
Time Domain
(default) | Frequency Domain
Specify the domain for computing autocorrelations as Time Domain
or Frequency Domain
. You must set this property to Time
Domain
for fixed-point signals.
Fixed-Point Properties
FullPrecisionOverride
— Full precision override for fixed-point arithmetic
true
(default) | false
Specify whether to use full precision rules. If you set FullPrecisionOverride
to true
, which is the default,
the object computes all internal arithmetic and output data types using full precision
rules. These rules provide the most accurate fixed-point numerics. It also turns off
the display of other fixed-point properties because they do not apply individually.
These rules guarantee that no quantization occurs within the object. Bits are added,
as needed, to ensure that no roundoff or overflow occurs. If you set FullPrecisionOverride
to false
,
fixed-point data types are controlled through individual fixed-point property
settings. For more information, see Full Precision for Fixed-Point System Objects.
RoundingMethod
— Rounding method for fixed-point operations
Floor
(default) | Ceiling
| Convergent
| Nearest
| Round
| Simplest
| Zero
Specify the rounding method as Ceiling
,
Convergent
, Floor
, Nearest
,
Round
, Simplest
, or
Zero
.
Dependencies
This property applies only when you set the Method
property
to Time Domain
and the object is not in full precision
mode.
OverflowAction
— Overflow action for fixed-point operations
Wrap
(default) | Saturate
Specify the overflow action as Wrap
or
Saturate
.
Dependencies
This property applies only when you set the Method
property
to Time Domain
and the object is not in full precision
mode.
ProductDataType
— Product word and fraction lengths
Full precision
(default) | Same as input
| Custom
Specify the product fixed-point data type as one of Full
precision
, Same as input
, or
Custom
.
Dependencies
This property applies only when you set the Method
property
to Time Domain
.
CustomProductDataType
— Product word and fraction lengths
numerictype([],32,30)
(default) | numerictype
Specify the product fixed-point type as a scaled numerictype
(Fixed-Point Designer) object with a Signedness
of
Auto
.
Dependencies
This property applies only when you set the Method
property
to Time Domain
and the ProductDataType
property to Custom
.
AccumulatorDataType
— Accumulator word and fraction lengths
Full precision
(default) | Same as product
| Same as input
| Custom
Specify the accumulator fixed-point data type as one of Full
precision
, Same as product
, Same as
input
, or Custom
.
Dependencies
This property applies only when the Method
property is
Time Domain
.
CustomAccumulatorDataType
— Accumulator word and fraction lengths
numerictype([],32,30)
(default) | numerictype
Specify the accumulator fixed-point type as a scaled numerictype
(Fixed-Point Designer) object with a Signedness
of
Auto
.
Dependencies
This property applies only when you set the Method
property
to Time Domain
and the AccumulatorDataType
property to Custom
.
OutputDataType
— Output word and fraction lengths
Same as accumulator
(default) | Same as product
| Same as input
| Custom
Specify the output fixed-point data type as Same as
accumulator
, Same as product
, Same as
input
, or Custom
.
Dependencies
This property applies only when the Method
property is
Time Domain
.
CustomOutputDataType
— Output word and fraction lengths
numerictype([],16,15)
(default) | numerictype
Specify the output fixed-point type as a scaled numerictype
(Fixed-Point Designer) object with a Signedness
of
Auto
.
Dependencies
This property applies only when you set the Method
property
to Time Domain
and the OutputDataType
property to Custom
.
Usage
Syntax
Input Arguments
x
— Data input
vector | matrix | N-D array
Data input, specified as a vector, matrix, or an N-D array. The
object accepts real-valued or complex-valued multichannel and multidimensional inputs.
The input can be a fixed-point signal when you set the Method
property to 'Time Domain'
. When the input signal is complex, the
output signal is complex.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
Output Arguments
y
— Autocorrelated output
vector | matrix | N-D array
Autocorrelated output of the two input signals. The size, data type, and complexity of the output matches that of the input signal.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
Object Functions
To use an object function, specify the
System object™ as the first input argument. For
example, to release system resources of a System object named obj
, use
this syntax:
release(obj)
Examples
Autocorrelation of Noisy Sine Wave
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; ac = dsp.Autocorrelator('MaximumLagSource',... 'Property','MaximumLag',MaxLag,'Scaling','Unity at zero-lag'); SigAutocorr = ac(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 the generated 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.
More About
Autocorrelation
Autocorrelation is the correlation of a signal with itself at different points in time.
For a deterministic discrete-time sequence, x(n), the autocorrelation is computed using the following relationship:
where h is the lag and * denotes the complex conjugate. If the input is a length N realization of a WSS stationary random process, rx(h) is an estimate of the theoretical autocorrelation:
where E{ } is the expectation operator. The Unity at zero-lag
normalization divides each sequence value by the autocorrelation or autocorrelation estimate at zero lag.
The most commonly used estimate of the theoretical autocorrelation of a WSS random process is the biased estimate:
Algorithms
Time-Domain Computation
When you set the computation domain to time, the algorithm computes the autocorrelation of the input signal in the time domain. The input signal can be a fixed-point signal in this domain.
The autocorrelation sequence, y, is computed using this equation:
y0,j is the zero-lag element in the jth column of the input.
i is the index of the lag.
j is the index of the input data column.
*
denotes the complex conjugate.M is the number of elements in each column.
l is the maximum positive lag for autocorrelation. When you choose to compute the autocorrelation with all nonnegative lags, l=M–1. Otherwise, l is the maximum nonnegative integer lag value specified.
u is an M-by-N input matrix.
Frequency-Domain Computation
When you set the computation domain to frequency, the algorithm computes the autocorrelation in the frequency domain.
In this domain, the algorithm computes the autocorrelation sequence by taking the Fourier transform of the input signal, multiplying the Fourier transform with its complex conjugate, and taking the inverse Fourier transform of the product. In this domain, depending on the input length, the algorithm can require fewer computations.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
See System Objects in MATLAB Code Generation (MATLAB Coder).
Version History
Introduced in R2012aR2023a: dsp.Autocorrelator
System object has been removed
The dsp.Autocorrelator
System object has been removed. Use the xcorr
function
instead.
Update Code
This table shows how to update existing code to use the xcorr
function.
Discouraged Usage | Recommended Replacement |
---|---|
This function computes correlation over nonnegative lags. No maximum lag When you do not specify maximum lag, the object computes autocorrelation using nonnegative lags [0 (M − 1)], where M is the length of the first dimension of the input. acObj = dsp.Autocorrelator;
% x is a column vector
x = (1:100)';
yObj = acObj(x);
figure;
stem(yObj) Specify maximum lag When you specify the maximum lag MaxLag, the object computes autocorrelation using lags in the range [0 MaxLag]. MaxLag = 20; acObjLag = dsp.Autocorrelator(MaximumLagSource='Property',... MaximumLag=MaxLag); % x is a column vector x = (1:100)'; yObjLag = acObjLag(x); figure; stem(yObjLag) | This function computes correlation over positive and negative lags. No maximum lag When you do not specify maximum lag, the function computes autocorrelation using lags in the range [−(M − 1) (M − 1)], where M is the length of the first dimension of the input. [yfn,lags] = xcorr(x); figure; stem(lags,yfn) Specify maximum lag When you specify the maximum lag MaxLag, the function computes autocorrelation using lags in the range [−MaxLag MaxLag]. [yfnLag,lags] = xcorr(x,MaxLag); figure; stem(lags,yfnLag) |
R2021b: dsp.Autocorrelator
System object will be removed
dsp.Autocorrelator
System object will be removed in a future release. Use the xcorr
function
instead.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)