Specify or Inherit Conditional Subsystem Initial Values

To initialize the input values of a conditional subsystem, initialize its Outport block, using one of these approaches:

  • Explicitly specify the initial values by listing them in the Block Parameters dialog box of the Outport block.

  • Inherit the initial values from the input signals.

    Note:   If the conditional subsystem is driving a Merge block in the same model, you do not need to specify an initial condition for the subsystem's Outport block.

Inherit Initial Values from the Input Signal

Valid sources for the Outport block to inherit its initial output value from are:

  • Output port of another conditionally executed subsystem

  • Merge block

  • Function-Call model reference block

  • Constant block (simplified initialization mode only)

  • IC block (simplified initialization mode only)

  • Stateflow® chart

How you configure the Outport block for inheriting initial values depends on whether the model uses simplified or classic initialization mode. For details about initialization modes, see Set Initialization Mode to Simplified or Classic.

  1. Set the Source of initial output value parameter to Dialog.

  2. In the Initial output parameter, enter an empty matrix ([]).

  3. Set the Output when disabled parameter to held.

Alternatively, if you use simplified initialization mode, you can inherit initial values by setting the Source of initial output value to Input signal.

When you update the block diagram in simplified mode, a badge appears next to the Outport block, as shown in the figure below. If an initial condition source is not a valid source for inheriting an initial value or if you choose not to inherit the initial value, no badge appears and the Outport block uses the default initial value of the output data type. For more information, see Initialize Signals and Discrete States.

Explicitly Specify an Initial Value

  1. Set the Source of initial output value parameter to Dialog.

  2. In the Initial output parameter, enter the initial value. Valid values include an empty matrix ([]) but not Inf or NaN.

When you select Dialog, you can also specify whether to hold or reset the output when the conditional subsystem is disabled. For more information, see Setting Output Values When the Conditional Subsystem Is Disabled.

    Note:   To explicitly specify an initial value in simplified initialization mode, do not specify an empty matrix ([]) or a Simulink.Signal object.

Setting Output Values When the Conditional Subsystem Is Disabled

Although a conditional subsystem does not execute while it is disabled, the output signal is still available to other blocks. While a conditional subsystem is disabled and you have specified not to inherit initial conditions from an input signal, you can hold the subsystem outputs at their previous values or reset them to their initial conditions.

Open the block dialog box for each Outport block. For the Output when disabled parameter:

  • Select held to maintain the most recent value.

  • Select reset to revert to the initial condition. Set the Initial output to the initial value of the output.

    Note:   If you are connecting the output of a conditionally executed subsystem to a Merge block, set Output when disabled to held to ensure consistent simulation results.

    If you are using simplified initialization mode, you must select held when connecting a conditionally executed subsystem to a Merge block. For more information, see Underspecified initialization detection.

    Note:   If an Outport in an enabled subsystem resets its output on disabling at a different rate from the rate of execution of subsystem contents, both the disabled and execution outputs write to the subsystem output. Hence, the subsystem might output unexpected results.

More About

Was this topic helpful?