If
Selecting a subsystem by condition if-else.
blockType: If
Path in the library:
|
Description
Block If implements logic if-else to control the execution of the subsystem.
Restrictions
Block If It has the following limitations:
-
The block does not support on-the-fly configurable parameters. Values for the parameters If expression (e.g., u1 ~= 0) and Elseif expressions (comma-separated list, e.g., u2 ~= 0, u3(2) < u2) It cannot be configured during simulation in normal mode or accelerator mode, as well as when executing generated code.
-
To implement on-the-fly configurable expressions
if-else, configure the expression outside the block If. For example, use the block Relational Operator to evaluate an expression outside the block If or add a custom parameter as an input to the block If.
Ports
Input
#
u
—
input signals for evaluating logical expressions
scalar
Details
The Inputs u1,u2,…,un must have the same data type.
Block If does not support Boolean data type.
| Data types |
|
| Complex numbers support |
I don’t |
Output
#
if
—
an action signal for a condition if
scalar
Details
An action signal for a condition if subsequent blocks.
| Data types |
|
| Complex numbers support |
I don’t |
#
else
—
an action signal for a condition else
scalar
Details
An action signal for a condition else subsequent blocks.
Dependencies
To use this port, check the box Show else condition
| Data types |
|
| Complex numbers support |
I don’t |
Parameters
Main
#
Number of inputs —
Number of input ports
Int64 integer
Details
Number of input ports. The block ports are labeled u1, u2,…, un, where n is equal to the number of specified inputs.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
Yes |
#
If expression (e.g., u1 ~= 0) —
logical expression if
String
Details
Blocks connected to the if port are executed when the expression associated with the port takes the value true (1):
-
u1 > 0— sending an action signal to the output port if the input value on port u1 is greater0. -
<logical expression>— logical expression. This expression is displayed on the block icon next to the if output port.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
No |
#
Elseif expressions (comma-separated list, e.g., u2 ~= 0, u3(2) < u2) —
logical expression elseif
String
Details
Blocks connected to the elseif port are executed if the expression associated with the port takes the value true (1), and all expressions if and else — false (0):
-
No Boolean expressions are specified by default and the elseif port is hidden.
-
<list of logical expressions>— a comma-separated list of logical expressions. These expressions are displayed on the block icon next to the elseif output port.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
No |
#
Show else condition —
port display management else
Logical
Details
If the expression on the if port and all expressions on the elseif port are false, then the else port sends a signal to execute the connected blocks.
-
If this option is checked, the else port is displayed on the block icon.
-
If this option is unchecked, the else port is hidden.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
No |
# Enable zero-crossing detection — zero crossing option
Details
Check this box to enable zero crossing detection.
| Default value |
|
| Program usage name |
|
| Tunable |
No |
| Evaluatable |
No |