Simulink Reference Previous page   Next Page
Relational Operator

Perform the specified relational operation on the inputs

Library

Logic and Bit Operations

Description

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.

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:

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 mode and Output data type parameters. The output equals 1 for TRUE and 0 for FALSE.

Data Type Support

The Relational Operator block accepts real or complex signals of any data type supported by Simulink, including fixed-point data types. However, if the Output data type mode parameter is set to Logical, the input may only be Boolean or double. One input can be real and the other complex if the operator is == or !=.

For a discussion on the data types supported by Simulink, refer to Data Types Supported by Simulink in the Using Simulink documentation.

Parameters and Dialog Box

The Main pane of the Relational Operator block appears as follows:

Relational Operator
Designate the relational operator used to compare the two inputs.
Enable zero crossing detection
Select to enable zero crossing detection. For more information, see Zero Crossing Detection in the Using Simulink documentation.
Sample time (-1 for inherited)
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 data types pane of the Relational Operator block appears as follows:

Require all inputs to have same data type
Select to require inputs to have the same data type.
Output data type mode
Set the output data type to Boolean, or choose to specify the data type through the Output data type parameter.
Alternatively, you can select Logical to have the output data type determined by the Implement logic signals as boolean data parameter in the Simulation and code generation optimization pane of the Configuration Parameters dialog box. If you select Logical and Boolean Logic Signals is on, then the output data type is always Boolean. If you select Logical and Implement logic signals as boolean data is off, then the output data type will match the input data type, then the output data type will match the input data type, which is always double.
Output data type
Specify the output data type. You should only use data types that represent zero exactly. Data types that satisfy this condition include signed and unsigned integers and any floating-point data type. This parameter is only visible if you select Specify via dialog for the Output data type mode parameter.

Characteristics

Direct Feedthrough
Yes
Sample Time
Specified in the Sample time parameter
Scalar Expansion
Yes, of inputs
Dimensionalized
Yes
Zero Crossing
Yes, if enabled.


Previous page  Real-Imag to Complex Relay Next page

© 1994-2005 The MathWorks, Inc.