dsp.Variance System object

Package: dsp

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.


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

H = dsp.Variance('PropertyName',PropertyValue,...) returns a variance System object, H, 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


cloneCreate variance object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset variance to zero
stepVariance of input


Compute the running variance for a signal:

 hvar = dsp.Variance;
 hvar.RunningVariance = true;
 x = randn(100,1);
 y = step(hvar, x); 
 % y(i) is the running variance of all values in the vector x(1:i)


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.

Introduced in R2012a

Was this topic helpful?