Moving Average (Variable Frequency)

Variable frequency moving average-value computation

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

  • Moving Average (Variable Frequency) block

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

u¯=1T0t0t0+T0u(t)dt,

where:

  • u(t) is the input signal.

  • T0 is equal to 1f

  • f is the fundamental frequency of the signal.

The moving average for discrete-time is calculated as:

u¯(k)=1T0i=0n1u(ki).

Assumptions and Limitations

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

Ports

Input

expand all

Moving average input, specified as a scalar or vector.

Data Types: single | double

Frequency, specified as a scalar or vector in Hz.

Data Types: single | double

Output

expand all

Moving average of the input signal, returned as a scalar or vector.

Data Types: single | double

Parameters

expand all

Initial frequency of the signal, in Hz. If you specify the initial frequency using a vector, it must match the dimensions of the input vector.

Minimum frequency of the signal, in Hz. If you specify the minimum frequency using a vector, it must match the dimensions of the input vector.

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? and Specify Sample Time.

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.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Introduced in R2020a