Skip to Main Content Skip to Search
Product Documentation

Performing Computations in Function-Call Subsystems

When to Use Function-Call Subsystems for Computations on Event-Based Signals

In some situations, the most appropriate way to implement a numerical computation involving event-based signals is to place the computational blocks inside the Function-Call Subsystem block. When using this block, set the Sample time type parameter of the Trigger block to triggered.

How to Set Up Function-Call Subsystems for Computations

  1. From the Ports & Subsystems library, copy the Function-Call Subsystem block from the Simulink into your model.

  2. Open the Function-Call Subsystem block by double-clicking it. Initially, the subsystem contains:

    • An Inport block connected to an Outport block. The Inport block represents an input signal that provides data but does not cause the subsystem to execute.

    • A block labeled "function". This block represents a function-call signal that causes the subsystem to execute.

  3. In the empty Function-Call Subsystem window, create the contents of the subsystem. Use Inport blocks to represent input from outside the subsystem that provides data but does not cause the subsystem to execute. Use Outport blocks to represent external output. To learn which blocks are suitable for use inside the subsystem, see Blocks Inside Subsystems with Event-Based Input Signals.

  4. At the upper level of your model hierarchy, create or identify the function-call signal that causes the subsystem to execute. To create this signal, you might need to do any of the following:

    • Create a function-call signal that indicates the occurrence of signal-based events or entity departure events. Use the Time-Based Function-Call Generator, Signal-Based Function-Call Generator or Entity Departure Function-Call Generator block.

    • Create a union of function-call signals using the Mux block.

    • Convert a function-call signal that originates from a block in the Simulink library set into an event-based function-call signal, using the Timed to Event Function-Call block.

  5. Connect data signals to the ports that correspond to the Inport blocks inside the subsystem. Connect the function-call signal to the port labeled function().

Behavior of Computations in Function-Call Subsystems

When a Function-Call Subsystem block has event-based input signals, it behaves as follows:

Refining the Behavior

Initial Value of the Subsystem Output

To change the initial value for an output signal of the subsystem, change the Initial output parameter of the corresponding Outport block.

Timing of Function Calls Versus Signal Updates

If your function-call signal executes the Function-Call Subsystem block before all the data signals are up to date, try prioritizing the function-call signal. By doing so, you defer the subsystem execution relative to other simultaneous events, such as signal updates. To prioritize a function-call signal, insert a Signal-Based Event to Function-Call Event block and configure it as in Example: Generating a Function Call with an Event Priority.

Suppressing Computations Selectively

To prevent certain function calls in the function-call signal from executing the Function-Call Subsystem block, use the techniques in Conditionalizing Events.

Examples That Use Function-Call Subsystems

  


Free SimEvents Evaluation Kit

Learn how you can use SimEvents discrete-event simulation capabilities through these technical resources.

Get free kit

Trials Available

Try the latest version of discrete-event simulation products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS