| Simulink® | ![]() |
Math Operations

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.
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.
The Main pane of the Abs block dialog box appears as follows:

Select to enable zero-crossing detection. For more information, see How Blocks Work with Zero-Crossing Detection.
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:

Specify the maximum value that the block should output. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
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.
Select to lock scaling of outputs. This parameter is visible only if you enter an expression for the Output data type parameter.
Select the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink Fixed Point User's Guide.
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 generated.
Direct Feedthrough | Yes |
Sample Time | Specified in the Sample time parameter |
Dimensionalized | Yes |
Multidimensionalized | Yes |
Zero-Crossing Detection | Yes, if enabled |
![]() | Blocks — Alphabetical List | Action Port | ![]() |

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 |