Conditional Subsystem Initial Output Values - MATLAB & Simulink (original) (raw)
Main Content
To initialize the output values for a conditional subsystem, initializeOutport blocks within the subsystem by using one of these methods:
- Inherit initial output values from input signals connected to theOutport blocks.
- Specify initial output values using Outport block parameters.
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 Outport block.
Inherit Initial Output Values from Input Signals
By default, for an Outport block, the software sets the Initial output parameter to[]
and Output when disabled parameter to held
. With these settings, Simulink® attempts to use input signals connected to conditional subsystemOutport blocks to initialize output values. (since R2024a)
Note
Before R2024a: If Source of initial output value parameter of an Outport block in a conditional subsystem is set to Input signal
, Simulink attempts to use input signals connected to conditional subsystem Outport blocks to initialize output values. You can replicate this behavior by setting the Source of initial output value parameter to Dialog
,Initial output parameter to []
and Output when disabled parameter toheld
.
Valid input signals for setting initial output values include:
- Output ports from another conditionally executed subsystem.
- Output ports from a Model block with a Trigger block with the Trigger type set to
function-call
. - Merge blocks.
- Constant blocks.
- IC (initial condition) blocks.
- Simulink signal objects with non-auto storage class attached to the signal lines connected to the Outport blocks. For the initial value of the signal objects to be effective, you must specify a value (for example,
"-1"
or'-1'
) other than an empty string scalar (""
) or an empty character vector (''
) for theInitialValue
parameter. For more information, see Use Simulink.Signal Objects to Specify and Control Signal Attributes. - Stateflow® charts.
- C Function blocks.
If the input signal is from a block not listed here, the Outport block uses the default initial value of the output data type.
When a conditional subsystem Outport block inherits its initial output value, after the model has been updated or run, an badge is displayed next to the Outport block.
You can also determine whether a conditional subsystem Outport block inherits its initial output value by using the [Simulink.getOutportInheritsInitialValue](../slref/simulink.getoutportinheritsinitialvalue.html)
function.
Note
Before R2024a: If you are using classic initialization mode, selecting Input signal
causes an error. To inherit the initial output value from an input signal, set the Source of initial output value parameter toDialog
, set Output when disabled parameter to held
, and setInitial output parameter to []
. The badge is not displayed in classic initialization mode. See, Classic Initialization Mode.
Specify Initial Output Values Using Dialog Parameters
Explicitly set the initial output values in cases where you want to:
- Test the behavior of a model with various initial values.
- Set initial values to steady state and reduce simulation time.
- Eliminate having to trace input signals to determine the initial output values.
To specify initial output values:
- Open the dialog box for an Outport block within a conditional subsystem.
- From the Source of initial output value options, select
Dialog
. This parameter is only available in releases before R2024a. For models from R2024a, skip this and go to the next step. - In the Initial output box, enter the initial value.