| Simulink® | ![]() |
Discrete

Note The Weighted Moving Average block is still supported, but The MathWorks plans to remove this block in a future release. Use the Discrete FIR Filter block instead. |
The Weighted Moving Average block samples and holds the N most recent inputs, multiplies each input by a specified value (given by the Weights parameter), and stacks them in a vector. This block supports both single-input/single-output (SISO) and single-input/multi-output (SIMO) modes.
For the SISO mode, the Weights parameter is specified as a row vector. For the SIMO mode, the weights are specified as a matrix where each row corresponds to a separate output. You can choose whether or not to specify the data type and scaling of the weights in the dialog with the Gain data type parameter.
The Initial condition parameter provides the initial values for all times preceding the start time. You specify the time interval between samples with the Sample time parameter.
The Weighted Moving Average block first multiplies its inputs by the Weights parameter, converts those results to the output data type using the specified rounding and overflow modes, and then carries out the summation.
The Weighted Moving Average block supports all data types supported by Simulink® software, including fixed-point data types.
The Main pane of the Weighted Moving Average block dialog appears as follows:

Specify the weights of the moving average; one row per output. The Weights parameter is converted from doubles to the specified data type offline using round-to-nearest and saturation.
Specify the initial values for all times preceding the start time. The Initial condition parameter is converted from doubles to the input data type offline using round-to-nearest and saturation.
Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See Specifying Sample Time in the online documentation for more information.
The Signal Attributes pane of the Weighted Moving Average block dialog appears as follows:

Specify the output data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via back propagation
The name of a data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, float('single')
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Output
data type parameter.
See Specifying Block Output Data Types for more information.
Select to lock scaling of outputs. This parameter is visible only if you enter an expression for the Output data type parameter.
Rounding mode for the fixed-point output. For more information, see Rounding in the Simulink® Fixed Point™ User's Guide.
If selected, fixed-point overflows saturate.
The Parameter Attributes pane of the Weighted Moving Average block dialog appears as follows:

Specify the data type of the Weights parameter. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via internal rule
The name of a data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Gain
data type parameter. (See Using the Data Type Assistant.)
Suppose you want to configure this block for two outputs (SIMO mode) where the first output is given by
![]()
the second output is given by
![]()
and the initial values of u(k - 1) and u(k - 2) are given by ic1 and ic2, respectively. To configure the Weighted Moving Average block for this situation, you must specify the Weights parameter as [a1 b1 c1; a2 b2 c2] where c2 = 0, and the Initial condition parameter as [ic1 ic2].
Direct Feedthrough | Yes |
Scalar Expansion | Yes, of initial conditions |
![]() | Variable Time Delay, Variable Transport Delay | Weighted Sample Time | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |