Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

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

  • A rule that inherits a data type, for example, Inherit: Inherit via back propagation

  • The name of a built-in data type, for example, single

  • 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 Output data type parameter.

See Specifying Block Output Data Types for more information.

Lock output data type setting against changes by the fixed-point tools

Select to lock the output data type setting of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor. For more information, see Fixed-Point Tool and Fixed-Point Advisor in the Simulink® Fixed Point™ documentation.

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:

  • For 8-bit integers, -128 maps to 127.

  • For 16-bit integers, -32768 maps to 32767.

  • For 32-bit integers, -2147483648 maps to 2147483647.

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

  • For 8-bit integers, -128 remains -128.

  • For 16-bit integers, -32768 remains -32768.

  • For 32-bit integers, -2147483648 remains -2147483648.

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

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