Simulink Reference Previous page   Next Page
Weighted Moving Average

Implement a weighted moving average

Library

Discrete

Description

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.

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.

You can choose whether or not to specify the data type and scaling of the weights in the dialog with the Gain data type and scaling parameter. If you select Specify via dialog for this parameter, the Parameter data type, Parameter scaling, and Parameter scaling mode parameters become visible.

You can specify the scaling for the weights with the Parameter scaling and Parameter scaling mode parameters. If Parameter data type is a generalized fixed-point number such as sfix(16), the Parameter scaling mode list provides you with these scaling modes:

If the weights are specified as a row vector, then scaling element-wise and column-wise produce the same result, while scaling matrix-wise and row-wise produce the same result.

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 data types supported by Simulink, including fixed-point data types.

Parameters and Dialog Box

The Main pane of the Weighted Moving Average block dialog appears as follows:

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 Specifying Sample Time in the online documentation for more information.

The Parameter data types pane of the Weighted Moving Average block dialog appears as follows:

Gain data type and scaling
Choose whether to specify the data type of the weights in the block dialog or via an internal rule. If you select Specify via dialog, the Parameter data type, Parameter scaling, and Parameter scaling mode parameters become visible.
Parameter data type
Specify the data type of the weights. This parameter is only visible if you select Specify via dialog for the Gain data type and scaling parameter.
Parameter scaling mode
This drop-down list enables you to specify the parameter scaling in the dialog or by an inherited rule. This parameter is only visible if you select Specify via dialog for the Gain data type and scaling parameter.
Parameter scaling
Set the scaling of the weights using binary point-only or [Slope Bias] scaling. Additionally, the Weights vector or matrix can be scaled using the constant vector or constant matrix scaling modes for maximizing precision. These scaling modes are available only for generalized fixed-point data types. This parameter is only visible if you select Specify via dialog for the Gain data type and scaling parameter.

The Signal data types pane of the Weighted Moving Average block dialog appears as follows:

Output data type and scaling
Specify the output data type and scaling via the dialog box, or inherit the data type and scaling from the driving block or by backpropagation.
Output data type
Specify the output data type.
Output scaling
Set the output scaling using binary point-only or [Slope Bias] scaling. These scaling modes are available only for generalized fixed-point data types.
Lock output scaling so autoscaling tool can't change it
If selected, Output scaling is locked. This feature is available only for generalized fixed-point output.
Round toward
Rounding mode for the fixed-point output.
Saturate to max or min when overflows occur
If selected, fixed-point overflows saturate.

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 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].

Characteristics

Direct Feedthrough
Yes
Scalar Expansion
Yes, of initial conditions


Previous page  Variable Transport Delay Weighted Sample Time Next page

© 1994-2005 The MathWorks, Inc.