dsp.MovingVariance
R2026bMoving variance
Description
The dsp.MovingVariance
System object™ computes the moving variance of the input signal along each channel,
independently over time. The object uses either the sliding window method or the exponential
weighting method to compute the moving variance. In the sliding window method, a window of
specified length is moved over the data, sample by sample, and the variance is computed over
the data in the window. In the exponential weighting method, the object subtracts each sample
of the data from the average, squares the difference, and multiplies the squared result with a
weighting factor. The object then computes the variance by adding all the weighted
data.
You can make the window length tunable by setting
the EnableTunableWindowLength property to true. In
this mode, use the TunableWindowLength property to change the window
length even after you pass some data to the object and the object is locked. The
MaxWindowLength property specifies the maximum allowed window
length. (since R2026b)
For more details, see Algorithms.
The dsp.MovingVariance object and the movvar function both compute the moving variance of the input signal. However,
the object can process large streams of real-time data and handle system states automatically.
The function performs one-time computations on data that is readily available and cannot
handle system states. For a comparison between the two, see System Objects vs MATLAB Functions.
To compute the moving variance of the input:
Create the
dsp.MovingVarianceobject 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
Syntax
Description
returns a moving
variance object, MovVar = dsp.MovingVarianceMovVar, using the default
properties.
sets the MovVar = dsp.MovingVariance(Len)WindowLength property to Len.
sets the MovVar = dsp.MovingVariance(Len,Overlap)WindowLength property to Len and the
OverlapLength property to Overlap.
specifies additional properties using MovVar = dsp.MovingVariance(PropertyName=Value)Name=Value
arguments. For example, to specify an exponential weighting factor of
0.2, set ForgettingFactor to
0.9
Properties
Usage
Syntax
Description
Input Arguments
Output Arguments
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
Algorithms
References
[1] Bodenham, Dean. “Adaptive Filtering and Change Detection for Streaming Data.” PH.D. Thesis. Imperial College, London, 2012.
Extended Capabilities
Version History
Introduced in R2016bSee Also
Functions
Objects
dsp.MovingMaximum|dsp.MovingMinimum|dsp.MovingAverage|dsp.MovingRMS|dsp.MovingStandardDeviation|dsp.MedianFilter


![Sliding window method for moving variance with window length 4 and input samples [-1, -2, 3, 2, 5, 2]. At each time step n=0 through n=5, the window fills with zeros until length 4 is reached, then moves along the data. Moving variance computes var for each window position, producing values 0.250, 0.916, 4.667, 5.667, 8.667, 2.000 at n=5](movvar_slidewin.png)
![Exponential weighting method for moving variance with forgetting factor 0.9. Three input frames: [2,3,4,5] at n=0 producing outputs [0.0000, 0.5000, 0.9982, 1.6587], [6,7,8,9] at n=1 producing outputs [2.4780, 3.4514, 4.5734, 5.8375], and [3,4,6,8] at n=2 producing outputs [6.2519, 5.5814, 4.7901, 4.9790]](movvar_expwei.png)