| Simulink Reference | ![]() |
Perform the specified logical operation on the input
Library
Description
The Logical Operator block performs the specified logical operation on its inputs. An input value is TRUE (1) if it is nonzero and FALSE (0) if it is zero.
You select the Boolean operation connecting the inputs with the Operator parameter list. The block updates to display the selected operator. The supported operations are given below.
The number of input ports is specified with the Number of input ports parameter. The output type is specified with the Output data type mode and/or the Output data type parameters. An output value is 1 if TRUE and 0 if FALSE.
| Note The output data type should represent zero exactly. Data types that satisfy this condition include signed and unsigned integers, and any floating-point data type. |
The size of the output depends on input vector size and the selected operator:
Scalar inputs are expanded to have the same dimensions as the nonscalar inputs.
If the block has more than one input, the output has the same dimensions as the inputs (after scalar expansion) and each output element is the result of applying the specified logical operation to the corresponding input elements. For example, if the specified operation is AND and the inputs are 2-by-2 arrays, the output is a 2-by-2 array whose top left element is the result of applying AND to the top left elements of the inputs, etc.
When configured as a multi-input XOR gate, this block performs an addition- modulo-two operation as mandated by the IEEE Standard for Logic Elements.
Data Type Support
The Logical 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.
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 Logical Operator block dialog appears as follows:
-1. See Specifying Sample Time in the online documentation for more information.
The Signal data types pane of the Logical Operator block dialog appears as follows:
Boolean, or choose to specify the data type through the Output data type parameter.
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 Implement logic signals as boolean data 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, which may be Boolean or double.
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 |
No |
| Level-2 M-File S-Function | Lookup Table | ![]() |
© 1994-2005 The MathWorks, Inc.