| Simulink® | ![]() |
Logic and Bit Operations

The Relational Operator block performs the specified comparison of its two inputs.
You select the relational operator connecting the two inputs with the Relational Operator parameter. The block updates to display the selected operator. The supported operations are given below. In each case, the first input corresponds to the top input port and the second input to the bottom input port. (See Changing the Orientation of a Block in the Simulink® documentation for a description of the port order for various block orientations.)
| Operation | Description |
|---|---|
== | TRUE if the first input is equal to the second input |
~= | TRUE if the first input is not equal to the second input |
< | TRUE if the first input is less than the second input |
<= | TRUE if the first input is less than or equal to the second input |
>= | TRUE if the first input is greater than or equal to the second input |
> | TRUE if the first input is greater than the second input |
You can specify inputs as scalars, arrays, or a combination of a scalar and an array:
For scalar inputs, the output is a scalar.
For array inputs, the output is an array of the same dimensions, where each element is the result of an element-by-element comparison of the input arrays.
For mixed scalar/array inputs, the output is an array, where each element is the result of a comparison between the scalar and the corresponding array element.
The input with the smaller positive range is converted to the data type of the other input offline using round-to-nearest and saturation. This conversion is performed prior to comparison.
The output data type is specified with the Output data type parameter. The output equals 1 for TRUE and 0 for FALSE.
Note The output data type selected should represent zero exactly. Data types that satisfy this condition include signed and unsigned integers and any floating-point data type. |
The Relational Operator block accepts real or complex signals of any data type supported by Simulink software, including fixed-point data types. One input can be real and the other complex if the operator is == or !=.
For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink® in the Simulink documentation.
The Main pane of the Relational Operator block appears as follows:

Designate the relational operator used to compare the two inputs.
Select to enable zero crossing detection. For more information, see Zero-Crossing Detection .
Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See Specifying Sample Time in the online documentation for more information.
The Signal Attributes pane of the Relational Operator block appears as follows:

Select to require inputs to have the same data type.
Specify the output data type. You can set it to:
| Option | Description |
|---|---|
| boolean | Specifies the output data type as boolean. |
| Inherit: Logical | Use the Implement logic signals as boolean data model configuration parameter (see Implement logic signals as boolean data (vs. double)) to specify the output data type. |
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.
Direct Feedthrough | Yes |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | Yes, of inputs |
Dimensionalized | Yes |
Multidimensionalized | Yes |
Zero Crossing | Yes, if enabled. |
![]() | Real-Imag to Complex | Relay | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |