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.Variance System object

Variance of input or sequence of inputs


The Variance object computes variance for an input or sequence of inputs.

To compute the variance of an input or sequence of inputs:

  1. Define and set up your variance System object™. See Construction.

  2. Call step to compute the variance according to the properties of dsp.Variance. 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.


The Running mode in the dsp.Variance System object will be removed in a future release. To compute the running variance in MATLAB®, use the dsp.MovingVariance System object instead.


var = dsp.Variance returns a variance System object, var, that computes the variance of an input or a sequence of inputs over the specified Dimension.

var = dsp.Variance('PropertyName',PropertyValue,...) returns a variance System object, var, with each specified property set to the specified value.



Enable calculation over time

Set this property to true to enable variance calculation over successive calls to the step method. The default is false.


Enable reset input port

Set this property to true to enable reset input port. When you set the property to true, specify a reset input for the step method. The running variance resets anytime the variance object achieves the condition you specify for the ResetCondition property. This property applies when you set the RunningVariance property to true. The default is false.


Reset condition for running variance mode

Specify which event resets the running variance as one of | Rising edge | Falling edge | Either edge | Non-zero |. This property applies when you set the ResetInputPort property to true.


Dimension to operate along

Specify how the object performs the variance calculation over the data as one of | All | Row | Column | Custom |. This property applies when you set the RunningVariance property to false. The default is Column.


Numerical dimension to operate along

Specify the input signal dimension (one-based value) the object uses to compute variance. The cannot exceed the number of dimensions in the input signal. This property applies when you set the Dimension property to Custom. The default is 1.

 Fixed-Point Properties


resetReset variance to zero
stepVariance of input
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).

Compute the running variance of the signal. That is, compute the variance of each sample in the input signal with respect to all the previous samples.

var = dsp.Variance;
var.RunningVariance = true;
input = randn(100,1);
variance = var(input);


This object implements the algorithm, inputs, and outputs described on the Variance block reference page. The object properties correspond to the block parameters, except:

  • Reset port block parameter corresponds to both the ResetCondition and the ResetInputPort object properties.

Extended Capabilities

Introduced in R2012a

Was this topic helpful?