Unary Minus

Negate input

  • Library:
  • Simulink / Math Operations

    HDL Coder / HDL Floating Point Operations

    HDL Coder / Math Operations

Description

The Unary Minus block negates the input.

Ports

Input

expand all

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

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

Output

expand all

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

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

Parameters

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 sample time as a value other than -1. For more information, see Specify Sample Time.

Dependencies

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

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Values: scalar or vector
Default: '-1'

Block Characteristics

Data Types

double | fixed point[a] | integer[a] | single

Direct Feedthrough

yes

Multidimensional Signals

yes

Variable-Size Signals

no

Zero-Crossing Detection

no

[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™.

See Also

Topics

Introduced before R2006a