Main Content

Unary Minus

Negate input

  • Unary Minus block

Simulink / Math Operations
HDL Coder / HDL Floating Point Operations
HDL Coder / Math Operations


The Unary Minus block negates the input.


expand all

This example shows how to compute the unary minus of a matrix input.



expand all

Input signal, specified as a scalar, vector, matrix, or N-D array.

Data Types: half | single | double | int8 | int16 | int32 | int64 | fixed point


expand all

Negation of the input signal. The output has the same data type and dimensions as the input.

Data Types: half | single | double | int8 | int16 | int32 | int64 | fixed point


expand all

Select to have integer overflows saturate. Otherwise, overflows wrap.

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.

For signed-integer data types, the unary minus of the most negative value is not representable by the data type. In this case, the Saturate on integer overflow check box controls the behavior of the block:

Parameter SettingBlock BehaviorExamples
Saturate on integer overflow = onValues saturate to the most positive value of the integer data type
  • For 8-bit signed integers, -128 maps to 127.

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

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

Saturate on integer overflow = offValues wrap to the most negative value of the integer data type
  • For 8-bit signed integers, -128 remains -128.

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

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

Programmatic Use

Block Parameter: SaturateOnIntegerOverflow
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Specify the time interval between samples. To inherit the sample time, set this parameter to -1. For more information, see Specify Sample Time.


This parameter is visible only if you set it to a value other than -1. To learn more, see Blocks for Which Sample Time Is Not Recommended.

Programmatic Use

Block Parameter: SampleTime
Type: string scalar or character vector
Default: "-1"

Block Characteristics

Data Types

double | fixed pointa | half | integera | single

Direct Feedthrough


Multidimensional Signals


Variable-Size Signals


Zero-Crossing Detection


a This block only supports signed fixed-point data types.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Version History

Introduced before R2006a