Main Content

Sign

Indicate sign of input

  • Sign block

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

Description

Block Behavior for Real Inputs

For real inputs, the Sign block outputs the sign of the input:

InputOutput
Greater than zero1
Equal to zero0
Less than zero–1

The Sign Block Behavior for Real Inputs example shows that, for vector and matrix inputs, the block outputs a vector or matrix where each element is the sign of the corresponding input element.

Block Behavior for Complex Inputs

When the input u is a complex scalar, the block output matches the MATLAB® result for:

sign(u) = u./ abs(u)

The Sign Block Behavior for Complex Issues example shows that when an element of a vector or matrix input is complex, the block uses the same formula that applies to scalar input.

Ports

Input

expand all

Input signal whose sign will determine the output.

The block supports complex input signals only for floating-point data types, double and single.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point
Complex Number Support: Yes

Output

expand all

Output signal that is the sign of the input signal.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean
Complex Number Support: Yes

Parameters

expand all

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

Programmatic Use

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

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

Dependencies

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

Boolean | double | fixed point | integer | single

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

yes

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

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced before R2006a

See Also