Documentation

# Moving Average

Moving average-value computation

• Library:
• Simscape / Electrical / Control / General Control

## Description

The Moving Average block computes the moving average value of the input signal. Use this block to filter higher frequency signal components and to smooth noisy signals.

### Equations

The moving average is computed based on a moving time window. The moving average for continuous-time is calculated as

`$\overline{u}=\frac{1}{{T}_{0}}\underset{{t}_{0}}{\overset{{t}_{0}+{T}_{0}}{\int }}u\left(t\right)dt$`

where:

• u(t) is the input signal,

• `${T}_{0}=\frac{1}{f}$`
• f is the fundamental frequency of the signal.

The moving average for discrete-time is calculated as:

`$\overline{u}\left(k\right)=\frac{1}{{T}_{0}}\sum _{i=0}^{n-1}u\left(k-i\right)$`

### Assumptions

• The output is initialized with the initial condition in the time interval ```[0, T0]```

## Ports

### Input

expand all

Input signal.

Data Types: `single` | `double`

### Output

expand all

Moving average of the input signal.

Data Types: `single` | `double`

## Parameters

expand all

Fundamental frequency of the signal, in Hz. If you specify the fundamental frequency using a vector, it must match the input vector dimension.

The initial value of the input signal.

Time between consecutive block executions. During execution, the block produces outputs and, if appropriate, updates its internal state. For more information, see What Is Sample Time? (Simulink) and Specify Sample Time (Simulink).

For inherited discrete-time operation, specify `-1`. For discrete-time operation, specify a positive integer. For continuous-time operation, specify `0`.

If this block is in a masked subsystem, or other variant subsystem that allows you to switch between continuous operation and discrete operation, promote the sample time parameter. Promoting the sample time parameter ensures correct switching between the continuous and discrete implementations of the block. For more information, see Promote Parameter to Mask (Simulink).