Main Content

If Action Subsystem

Subsystem whose execution is enabled by If block

  • Library:
  • Simulink / Ports & Subsystems

  • If Action Subsystem block

Description

TheIf Action Subsystemblock is aSubsystemblock preconfigured as a starting point for creating a subsystem whose execution is controlled by anIfblock. TheIfblock evaluates a logical expression and then, depending on the result of the evaluation, outputs an action signal. Execution of the subsystem is controlled by anAction Portblock placed inside the subsystem.

金宝app®ignores a priority set on anIf Action Subsystemblock. Instead, set the priority on theIfblock that initiates execution of the subsystem.

Merge signals fromIf Action Subsystemblocks

This example shows how to merge signals controlled by anIfblock. TheIfblock selects the execution of anIf Action Subsystemblock from a set of subsystems. Regardless of which subsystem the If block selects, you can create a single signal with aMergeblock. To open the model, seeex_if_block.

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

Support for Fixed-Point Data Type

TheIfblock does not directly support fixed-point data types. However, you can use theCompare To Constantblock to work around this limitation.

Consider the following floating-point model without fixed-point data types. To open model, seeex_if_block_floating_point.

In this model, theIf Action Subsystemblocks 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

停止时间

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 inputu1is greater than0or inputu2is greater than0.5, the output is4. Otherwise, the output is-4. TheScopeblock displays the output from theMergeblock with inputsu1, andu2.

You can implement this block diagram as a model with fixed-point data types. To open model, seeex_if_block_fixed_point.

TheRepeating Sequence Stairblocks output fixed-point data types.

TheCompare To Constantblocks implement two parts of theIf expressionthat is used in theIfblock in the floating-point version of the model,(u1 > 0)and(u2 > 0.5). TheORoperation,(u1|u2), can still be implemented inside theIfblock. For a fixed-point model, the expression must be partially implemented outside of theIf块,我s 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

出put data type mode

Boolean

Enable zero-crossing detection

off

Compare To Constant1

Operator

>

Constant value

0.5

出put data type mode

Boolean

Enable zero-crossing detection

off

If

Number of inputs

2

If expression

u1|u2

Ports

Input

expand all

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

UseInportblocks to get signals from the local environment.

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

Placing anAction Portblock in a subsystem block adds an external input port to the block and changes the block to anIf Action Subsystem.

Dot-dash lines from aSwitch Caseblock to anSwitch Case Action Subsystemblock representactionsignals. 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

出put

expand all

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

Use出portblocks to send signals to the local environment.

Data Types:一半|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]|一半[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