Perform Computations Without Using Subsystems

When to Perform Computations on Event-Based Signals Without Using Subsystems

In some situations, you can perform computations on an event-based signal by connecting it directly to computational blocks, without putting the blocks in an Atomic Subsystem or Function-Call Subsystem block. Direct connections make the model easier to construct.

How to Set Up Blocks for Computations

Insert computational blocks into your model and connect them directly to event-based signals. If the block has a Sample time parameter in the block dialog box, you must set Sample time to -1 to indicate an inherited sample time.

Behavior of Computations

When a connected set of computational blocks has event-based input signals, the behavior depends on whether the blocks are in a nonvirtual subsystem, such as an Atomic Subsystem or Function-Call Subsystem block.

  • When a nonvirtual subsystem executes, the application determines an execution sequence that accounts for data dependencies among the blocks. Each block in the subsystem executes once, in that predetermined sequence.

  • Without the nonvirtual subsystem, event-based input signals execute blocks upon the sample time hits of those input signals.

For details about how blocks behave when they have event-based input signals and are not in a nonvirtual subsystem, see Execution of Blocks with Event-Based Inputs.

Refining the Behavior

Initial Value of Event-Based Signals

To change the initial value for any event-based signal that is not in a nonvirtual subsystem, connect the signal to the Initial Value block.

Migrate from Direct Connections to Atomic Subsystem

As you build your model, it might evolve from a situation in which direct connections of event-based signals to computational blocks is appropriate, to a situation in which it is better to perform the computation in an Atomic Subsystem block. Be alert to changes that your computation involves a block that has any of these characteristics:

  • The block does not support event-based input signals.

  • You do not want the block to respond immediately to each sample time hit of each event-based input signal.

To migrate your computation to an Atomic Subsystem block, see Create an Atomic Subsystem from Existing Blocks.

Examples That Perform Computations Without Using Subsystems

Was this topic helpful?