Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Moving average

The `dsp.MovingAverage`

System
object™ computes
the moving average 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 average. In the
sliding window method, a window of specified length is moved over
the data, sample by sample, and the average is computed over the data
in the window. In the exponential weighting method, the object multiplies
the data samples with a set of weighting factors. The average is computed
by summing the weighted data. For more details on these methods, see Algorithms.

The object accepts multichannel inputs, that is, *m*-by-*n* size
inputs, where *m* ≥ 1, and *n* >
1. The object also accepts variable-size inputs. Once the object is
locked, you can change the size of each input channel. However, the
number of channels cannot change. This object supports C and C++ code
generation.

To compute the moving average of the input:

Create a

`dsp.MovingAverage`

object and set the properties of the object.Call

`step`

to compute the moving average.

Alternatively, 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.

`movAvg = dsp.MovingAverage`

returns a moving
average object, `movAvg`

, using the default properties.

`movAvg = dsp.MovingAverage(Len)`

sets the `WindowLength`

property
to `Len`

.

`movAvg = dsp.MovingAverage(Name,Value)`

specifies
additional properties using `Name,Value`

pairs. Unspecified
properties have default values.

**Example**:

movAvg = dsp.MovingAverage('Method','Exponential weighting','ForgettingFactor',0.9);

reset | Reset internal states of System object |

step | Moving average of input signal |

Common to All System Objects | |
---|---|

`clone` | Create System object with same property values |

`getNumInputs` | Expected number of inputs to a System object |

`getNumOutputs` | Expected number of outputs of a System object |

`isLocked` | Check locked states of a System object (logical) |

`release` | Allow System object property value changes |

[1] Bodenham, Dean. “Adaptive Filtering and Change Detection for Streaming Data.” PH.D. Thesis. Imperial College, London, 2012.

`dsp.MedianFilter`

|`dsp.MovingMaximum`

|`dsp.MovingMinimum`

|`dsp.MovingRMS`

|`dsp.MovingStandardDeviation`

|`dsp.MovingVariance`

Was this topic helpful?