Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Weighted Moving Average (Obsolete) - Implement weighted moving average (obsolete)

Library

Discrete (until R2007b)

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

Data Type Support

The Weighted Moving Average block supports all numeric data types supported by Simulink software, including fixed-point data types.

Parameters and Dialog Box

The Main pane of the Weighted Moving Average block dialog box 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 How to Specify the Sample Time in the online documentation for more information.

The Signal Attributes pane of the Weighted Moving Average block dialog box appears as follows:

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

Lock output scaling against changes by the autoscaling tool

Select to lock scaling of outputs. This parameter is visible only if you enter an expression for the Output data type parameter.

Round toward

Rounding mode for the fixed-point output. For more information, see Rounding in the Simulink Fixed Point User's Guide.

Saturate to max or min when overflows occur

If selected, fixed-point overflows saturate.

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

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

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

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS