Moving Average

Block-library: DUBSI

   block

The Moving Average block computes the average of a user-determined number of samples of the input signal, which are all evenly-spaced in time. The average is 'moving' in time, because at each sample time the oldest sample is replaced by a new sample, according to the 'last in, first out' principle.

This 'digital moving average filter' is represented by the following equation 1):

equation

where k is the current sample number (k = 1, 2, 3, ...), y is the output signal, u is the input signal, and ns is the total number of samples. The actual time at the kth sample interval equals k*ts, where ts is the sample time.

The user must specify the following block-parameters:

  • the number of samples ns
  • the sample time ts
  • the initial value of the signal.

The initial value of the signal is required in order to prevent transient errors during the first ns samples in a simulation.


1) Notice that in practice, the equation for the moving average filter has been implemented by means of a Discrete State Space block, as follows:

equation

Here, x has been introduced as intermediate 'state variable'. The 'last in, first out' action takes place in the first equation, while the actual averaging is done in the second one. Resolving this equation for a certain sequence of k values will reveil the simple y(k) equation for the moving average filter, which was discussed earlier.

April 15, 2003