Weighted Moving Average (Obsolete)
Implement weighted moving average
Library
Discrete (until R2007b)
Description
Note
The Weighted Moving Average block is obsolete. This block was removed from the Discrete library in R2008a and replaced with the Discrete FIR Filter block. However, existing models that contain the Weighted Moving Average block continue to work for backward compatibility.
Use the Discrete FIR Filter block in new
models. Consider using the upgradeadvisor function to replace
Weighted Moving Average with Discrete FIR Filter in existing models. See Programmatically Analyze and Upgrade Model.
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 box 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.
Data Type Support
The Weighted Moving Average block supports all numeric data types that Simulink® supports, including fixed-point data types.
Parameters
- Weights
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.
- Initial condition
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.
- Sample time
Specify the time interval between samples. To inherit the sample time, set this parameter to
-1. See Specify Sample Time in the online documentation for more information.
- Output data type
Specify the output data type. You can set it to:
A rule that inherits a data type, for example,
Inherit: Inherit via back propagationThe name of a data type object, for example, a
Simulink.NumericTypeobjectAn 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 Output data
type parameter.See Control Data Types of Signals for more information.
- Lock output scaling against changes by the autoscaling tool
Select to lock scaling of outputs against changes by the Fixed-Point Tool.
- Integer rounding mode
Rounding mode for the fixed-point output. For more information, see Rounding Modes (Fixed-Point Designer).
- Saturate to max or min when overflows occur
If selected, fixed-point overflows saturate. Otherwise, they wrap.
- Gain data type
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 ruleThe name of a data type object, for example, a
Simulink.NumericTypeobjectAn 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 Specify Data Types Using Data Type Assistant
for more information.)
Examples
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 case,
you must specify the Weights parameter as [a1
b1 c1; a2 b2 c2] where c2 = 0, and the Initial
condition parameter as [ic1 ic2].
Characteristics
Direct Feedthrough | Yes |
Scalar Expansion | Yes, of initial conditions |