Logical Operator
Performs the specified logical operation on the input signals.
blockType: Logic
Path in the library:
|
Description
Block Logical Operator performs a specified logical operation for one or more operands. The input value is interpreted as true (1) if it is not equal to zero, and false (0) if it is equal to zero.
A specific logical operation can be selected in the block settings using the parameter Operator.
The table shows the supported logical operations.:
| Operation | Description |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The block icon changes depending on which option is selected. Operator a logical operation. The number of input ports is set in the parameter Number of input ports.
The output size depends on the size of the input vector and the selected operator.:
-
If the block has more than one input, the dimension of the remaining ports is expanded to the maximum possible using broadcast operations. For example, if the input signals have dimensions
4on1,1on5and1on1, then using broadcast , the output will be an array of the size4on5. This process automatically expands arrays by dimensions equal to one in order to match the dimensions of the input data for calculations.Broadcast is the process of automatically reducing arrays to compatible sizes for performing operations. Broadcast works according to the rules of "distribution" in dimensions equal to one: if the arrays have mismatched sizes, but at least one of the dimensions is equal to 1, then the operation is performed, while the array is expanded in the corresponding dimension.The dimension of scalar input signals increases to the dimension of non-scalar input signals, which is also achieved using the broadcast operation. If a block has several inputs, and one of them is scalar, broadcast automatically expands it to the same dimension as the rest of the input data.
If the block has more than one input, the output has the same dimensions as the inputs, and each output element is the result of applying the specified logical operation to the corresponding input elements. For example, if an operation is specified
AND, and the input data are arrays2on2, the output will be an array2on2, the upper -left element of which is the result of the applicationANDto the upper-left elements of the input data, and so on. -
For one input vector, the block applies an operation (except the operator
NOT) to all elements of the vector. The output in this case is always a scalar. -
Operator
NOTaccepts only one input, which can be a scalar or a vector. If the input is a vector, the output is a vector of the same size containing the logical complements of the elements of the input vector.
Ports
Output
#
OUT_1
—
The output signal
scalar | vector | the matrix
Details
The output signal consists of zeros and ones, with the same dimensions as the input.
| Data types |
|
| Complex numbers support |
Yes |
Input
#
IN_1
—
the first input signal
scalar | vector | the matrix
Details
The first input signal. A scalar, vector, or matrix.
| Data types |
|
| Complex numbers support |
Yes |
#
IN_2
—
the second input signal
scalar | vector | the matrix
Details
The second input signal. A scalar, vector, or matrix.
| Data types |
|
| Complex numbers support |
Yes |
Parameters
Main
#
Operator —
The logical operator
AND | OR | NAND | NOR | XOR | NXOR | NOT
Details
Select the logical operator that will be applied to the input signals of the block:
-
AND—trueif all the inputs arefalse. -
OR—trueif there is at least one inputtrue. -
NAND—trueif there is at least one inputfalse. -
NOR—truewhen there is no input data in the valuetrue. -
XOR—trueif there are an odd number of inputstrue. -
NXOR—trueif there are an even number of inputstrue. -
NOT—trueIf the input isfalse.
| Values |
|
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
No |
#
Number of input ports —
number of inputs
Int64 integer
Details
Set the number of input ports of the block as a positive integer.
Dependencies
To use this parameter, set for the parameter Operator any value other than NOT.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |