Skip to Main Content Skip to Search
Product Documentation

Weighted Sample Time Math - Support calculations involving sample time

Library

Math Operations

Description

The Weighted Sample Time Math block adds, subtracts, multiplies, or divides its input signal, u, by a weighted sample time, Ts. If the input signal is continuous, Ts is the sample time of the Simulink model. Otherwise, Ts is the sample time of the discrete input signal.

You specify the math operation with the Operation parameter. Additionally, you can specify to use only the weight with either the sample time or its inverse.

Enter the weighting factor in the Weight value parameter. If the weight, w, is 1, that value does not appear in the equation on the block icon.

The block computes its output using the precedence rules for MATLAB operators (see Operator Precedence). For example, if the Operation parameter specifies +, the block calculates output using this equation:

u + (Ts * w)

However, if the Operation parameter specifies /, the block calculates output using this equation:

(u / Ts) / w

Data Type Support

The Weighted Sample Time Math block accepts signals of the following data types:

For more information, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

The Main pane of the Weighted Sample Time Math block dialog box appears as follows:

Operation

Specify operation to use: +, -, *, /, Ts Only, or 1/Ts Only.

Weight value

Enter the weight of sample time.

Implement using

Select one of two modes: online calculations or offline scaling adjustment. This parameter is visible only when you set Operation to * or /.

Result of (Ts * w)Output Data Type of Two ModesBlock Execution
A power of 2, or an integer valueThe same, when Output data type is Inherit: Inherit via internal ruleEqually efficient in both modes
Not power of 2 and not an integer valueDifferentMore efficient for the offline scaling mode

    Note   When the Implement using parameter is not visible, operations default to online calculations.

The Signal Attributes pane of the Weighted Sample Time Math block dialog box appears as follows:

Output data type

Specify whether the block inherits the output data type by an internal rule or back propagation.

    Tip   If you enter an expression in the edit field, the expression must evaluate to one of the two inherit rules.

Integer rounding mode

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

Saturate on integer overflow
ActionReasons for Taking This ActionWhat Happens for OverflowsExample

Select this check box.

Your model has possible overflow and you want explicit saturation protection in the generated code.

Overflows saturate to either the minimum or maximum value that the data type can represent.

An overflow associated with a signed 8-bit integer can saturate to -128 or 127.

Do not select this check box.

You want to optimize efficiency of your generated code.

You want to avoid overspecifying how a block handles out-of-range signals. For more information, see Checking for Signal Range Errors.

Overflows wrap to the appropriate value that is representable by the data type.

The number 130 does not fit in a signed 8-bit integer and wraps to -126.

When you select this check box, saturation applies to every internal operation on the block, not just the output or result. In general, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.

Characteristics

Direct Feedthrough

For all math operations except Ts and 1/Ts

Scalar Expansion

No, the weight is always a scalar

Zero-Crossing Detection

No

  


Related Products & Applications

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

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