# Moving Average (Variable Frequency)

**Libraries:**

Simscape /
Electrical /
Control /
General Control

## Description

The Moving Average (Variable Frequency) block computes the moving average value of an input signal of variable frequency. 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}}{\displaystyle \underset{{t}_{0}}{\overset{{t}_{0}+{T}_{0}}{\int}}u(t)dt},$$

where:

*u(t)*is the input signal.*T*is equal to $$\frac{1}{f}$$_{0}*f*is the fundamental frequency of the signal.

The moving average for discrete-time is calculated as:

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

**Note**

If you use this block for continuous-time operations and set the
**Sample time (-1 for inherited)** parameter to
`0`

, you should also specify the value of the
**Buffer size** parameter to ensure it covers the
moving time window.

### Assumptions and Limitations

The output is initialized with an initial condition in the time interval

`[0,`

.*T*]_{0}If you use this block for discrete-time operations and set the

**Sample time (-1 for inherited)**parameter to`-1`

, the maximum variable integer delay is set to 4096 samples. To compute the maximum variable integer delay as a function of minimum frequency and sample time, set the**Sample time (-1 for inherited)**parameter to a positive value.

## Ports

### Input

### Output

## Parameters

## Extended Capabilities

## Version History

**Introduced in R2020a**