Abs - Output absolute value of input

Library

Math Operations

Description

The Abs block outputs the absolute value of the input.

For signed data types, the absolute value of the most negative value is problematic since it is not representable by the data type. In this case, the behavior of the block is controlled by the Saturate on integer overflow check box. If selected, the absolute value of the data type saturates to the most positive representable value. If not selected, the absolute value of the most negative value represented by the data type has no effect.

For example, suppose the block input is an 8-bit signed integer. The range of this data type is from -128 to 127, and the absolute value of -128 is not representable. If you select the Saturate on integer overflow check box, then the absolute value of -128 is 127. If it is not selected, then the absolute value of -128 remains at -128.

Data Type Support

The Abs block accepts real signals of any numeric data type supported by Simulink® software, except Boolean. The Abs block supports real fixed-point data types. The block also accepts complex floating-point inputs.

For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink.

Parameters and Dialog Box

The Main pane of the Abs block dialog box appears as follows:

Enable zero-crossing detection

Select to enable zero-crossing detection. For more information, see How Blocks Work with Zero-Crossing Detection.

Sample time (-1 for inherited)

Enter the time interval between sample time hits or specify another appropriate sample time such as continuous. By default, the block inherits its sample time based upon its context within the model. See Working with Sample Times.

The Signal Attributes pane of the Abs block dialog box appears as follows:

Output maximum

Specify the maximum value that the block should output. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:

Output data type

Specify the output data type. You can set it to:

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.

Integer rounding mode

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

Saturate on integer overflow

Select to have overflows saturate. If selected, the block maps signed integer input elements corresponding to the most negative value of that data type to the most positive value of that data type:

Otherwise, the block does not act on signed integer input elements corresponding to the most negative value of that data type:

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 which case, no saturation code is generated.

Characteristics

Direct Feedthrough

Yes

Sample Time

Specified in the Sample time parameter

Dimensionalized

Yes

Multidimensionalized

Yes

Zero-Crossing Detection

Yes, if enabled

  


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