If Action Subsystem

Subsystem whose execution is enabled by an If block

  • Library:
  • Simulink / Ports & Subsystems

  • If Action Subsystem block

Description

The If Action Subsystem block is a Subsystem block preconfigured as a starting point for creating a subsystem whose execution is controlled by an If block. The If block evaluates a logical expression and then, depending on the result of the evaluation, outputs an action signal.

Simulink ignores a priority set on an If Action Subsystem block. Instead, set the priority on the If block that initiates execution of the subsystem.

Merge signals from If Action Subsystem blocks

This example shows how to merge signals controlled by an If block. The If block selects the execution of an If Action Subsystem block from a set of subsystems. Regardless of which subsystem the If block selects, you can create a single signal with a Merge block. Open model.

All blocks in an If Action Subsystem block must execute at the same rate as the driving If block. You can satisfy this requirement by setting the sample time parameter for each block to either inherited (-1) or the same value as the If block sample time.

Support for Fixed-Point Data Type

The If block does not directly support fixed-point data types. However, you can use the Compare To Constant block to work around this limitation.

Consider the following floating-point model without fixed-point data types:

In this model, the If Action Subsystem blocks use their default configurations. The simulation parameters are set to their default values except for the parameters listed in the following table.

Configuration Parameter Pane

Parameter

Setting

Solver

Start time

0.0

 

Stop time

1.0

 

Type

Fixed-step

 

Solver

discrete (no continuous states)

 

Fixed-step size

0.1

The block parameters are set to their default values except for the parameters listed in the following table.

Block

Parameter

Setting

Repeating Sequence Stair

Vector of output values

[-2 -1 1 2].'

Repeating Sequence Stair1

Vector of output values

[0 0 0 0 1 1 1 1].'

If

Number of inputs

2

 

If expression

(u1 > 0) | (u2 > 0.5)

 

Show else condition

Selected

Constant

Constant value

-4

Constant1

Constant value

4

Scope

Number of axes

3

 

Time range

1

For this model, when input u1 is greater than 0 or input u2 is greater than 0.5, the output is 4. Otherwise, the output is -4. The Scope block displays the output from the Merge block with inputs u1, and u2.

You can implement this block diagram as a model with fixed-point data types:

The Repeating Sequence Stair blocks output fixed-point data types.

The Compare To Constant blocks implement two parts of the If expression that is used in the If block in the floating-point version of the model, (u1 > 0) and (u2 > 0.5). The OR operation, (u1|u2), can still be implemented inside the If block. For a fixed-point model, the expression must be partially implemented outside of the If block as it is in this model.

The block and simulation parameters for the fixed-point model are the same as for the floating-point model with the following exceptions and additions:

Block

Parameter

Setting

Compare To Constant

Operator

>

 

Constant value

0

 

Output data type mode

Boolean

 

Enable zero-crossing detection

off

Compare To Constant1

Operator

>

 

Constant value

0.5

 

Output data type mode

Boolean

 

Enable zero-crossing detection

off

If

Number of inputs

2

 

If expression

u1|u2

Ports

Input

expand all

Placing an Inport block in a subsystem block adds an external input port to the block. The port label matches the name of the Inport block.

Use Inport blocks to get signals from the local environment.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus

Placing an Action Port block in a subsystem block adds an external input port to the block and changes the block to an If Action Subsystem.

Dot-dash lines from a Switch Case block to an Switch Case Action Subsystem block represent action signals. An action signal is a control signal connected to the action port of a Switch Case Action Subsystem block. A message on the action signal initiates execution of the subsystem.

Data Types: action

Output

expand all

Placing an Outport block in a subsystem block adds an output port from the block. The port label on the subsystem block is the name of the Outport block.

Use Outport blocks to send signals to the local environment.

Data Types: half | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated | bus

Block Characteristics

Data Types

Boolean[a] | bus[a] | double[a] | enumerated[a] | fixed point[a] | half[a] | integer[a] | single[a] | string[a]

Direct Feedthrough

no

Multidimensional Signals

limited[a]

Variable-Size Signals

limited[a]

Zero-Crossing Detection

no

[a] Actual data type or capability support depends on block implementation.

Extended Capabilities

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Introduced before R2006a