Main Content

Sign

Indicate sign of input

  • Sign block

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

Description

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

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

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

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

Examples

expand all

This example shows how, for vector and matrix inputs, the block outputs a vector or matrix where each element is the sign of the corresponding input element.

model='ex_sign_block_matrix_input_real.slx';
open_system(model)

This example shows how, when an element of a vector or matrix input is complex, the block uses the same formula that applies to scalar input.

model='ex_sign_block_matrix_input_complex.slx';
open_system(model)

Extended Examples

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

To set the block parameter value programmatically, use the set_param function.

Parameter: SampleTime
Values: "-1" (default) | scalar or vector in quotes

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