Simulink Reference Previous page   Next Page
Logical Operator

Perform the specified logical operation on the input

Library

Logic and Bit Operations

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.

Operation
Description
AND
TRUE if all inputs are TRUE
OR
TRUE if at least one input is TRUE
NAND
TRUE if at least one input is FALSE
NOR
TRUE when no inputs are TRUE
XOR
TRUE if an odd number of inputs are TRUE
NOT
TRUE if the input is FALSE

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.

The size of the output depends on input vector size and the selected operator:

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:

Operator
The logical operator to be applied to the block inputs. Valid choices are the operators listed previously.
Number of input ports
The number of block inputs. The value must be appropriate for the selected operator.
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 Logical Operator block dialog appears as follows:

Require all inputs and output to have same data type
Select to require all inputs and the output 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 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.
Output data type
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
No


Previous page  Level-2 M-File S-Function Lookup Table Next page

© 1994-2005 The MathWorks, Inc.