| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
| On this page… |
|---|
Blocks an Enabled Subsystem Can Contain Using Blocks with Constant Sample Times in Enabled Subsystems |
Enabled subsystems are subsystems that execute at each simulation step where the control signal has a positive value.
An enabled subsystem has a single control input, which can be scalar or vector valued.
If the input is a scalar, the subsystem executes if the input value is greater than zero.
If the input is a vector, the subsystem executes if any of the vector elements is greater than zero.
For example, if the control input signal is a sine wave, the subsystem is alternately enabled and disabled, as shown in this figure. An up arrow signifies enable, a down arrow disable.

The Simulink software uses the zero-crossing slope method to determine whether an enable is to occur. If the signal crosses zero and the slope is positive, the subsystem is enabled. If the slope is negative at the zero crossing, the subsystem is disabled.
You create an enabled subsystem by copying an Enable block from the Ports & Subsystems library into a subsystem. An enable symbol and an enable control input port is added to the Subsystem block.
![]()
You can set the initial output of an enabled subsystem using the subsystems Outport blocks. The initial output value can be either explicitly specified, or inherited from its input signal.
Specifying Initial Conditions. To specify the initial output value of the subsystem:
Double-click each Outport block in the subsystem to open its dialog box.
Select Dialog in the Source of initial output value drop-down list.
Specify the Initial output parameter.
If you select Dialog, you can also specify what happens to the output when the subsystem is disabled. For more information, see the next section: Setting Output Values While the Subsystem Is Disabled.
Inheriting Initial Conditions. The initial output value of the subsystem can be inherited from the following sources:
Output port of another conditionally executed subsystem
Merge block (with Initial output specified)
Function-Call Model Reference block
Constant block (simplified initialization mode only)
IC block (simplified initialization mode only)
The procedure you use to inherit the initial conditions of the subsystem differs depending on whether you are using classic initialization mode or simplified initialization mode.
To inherit initial conditions in classic initialization mode:
Double-click each Outport block in the subsystem to open its dialog box.
Select Dialog in the Source of initial output value drop-down list.
Set the Initial output parameter to [] (empty matrix).
Click OK.
To inherit initial conditions in simplified initialization mode:
Double-click each Outport block in the subsystem to open its dialog box.
Select Input signal in the Source of initial output value drop-down list.
Click OK.
The Initial output and Output when disabled parameters are disabled, and the values are both inherited from the input signal.
For more information on classic and simplified initialization mode, see Underspecified initialization detection.
Although an enabled subsystem does not execute while it is disabled, the output signal is still available to other blocks. While an enabled subsystem is disabled, you can choose to hold the subsystem outputs at their previous values or reset them to their initial conditions.
Open each Outport block's dialog box and select one of the choices for the Output when disabled parameter, as shown in the following dialog box:
Choose 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. |
When an enabled subsystem executes, you can choose whether to hold the subsystem states at their previous values or reset them to their initial conditions.
To do this, open the Enable block dialog box and select one of the choices for the States when enabling parameter:
Choose held to cause the states to maintain their most recent values.
Choose reset to cause the states to revert to their initial conditions.

Note If you are using simplified initialization mode, subsystem elapsed time is always reset on first execution after becoming enabled, whether or not the subsystem is configured to reset on enable. For more information on simplified initialization mode, see Underspecified initialization detection. |
An option on the Enable block dialog box lets you output the enable control signal. To output the control signal, select the Show output port check box.

This feature allows you to pass the control signal down into the enabled subsystem, which can be useful where logic within the enabled subsystem is dependent on the value or values contained in the control signal.
An enabled subsystem can contain any block, whether continuous or discrete. Discrete blocks in an enabled subsystem execute only when the subsystem executes, and only when their sample times are synchronized with the simulation sample time. Enabled subsystems and the model use a common clock.
Note Enabled subsystems can contain Goto blocks. However, only state ports can connect to Goto blocks in an enabled subsystem. See the demo model, clutch, for an example of how to use Goto blocks in an enabled subsystem. |
For example, this system contains four discrete blocks and a control signal. The discrete blocks are
Block A, which has a sample time of 0.25 second
Block B, which has a sample time of 0.5 second
Block C, within the enabled subsystem, which has a sample time of 0.125 second
Block D, also within the enabled subsystem, which has a sample time of 0.25 second
The enable control signal is generated by a Pulse Generator block, labeled Signal E, which changes from 0 to 1 at 0.375 second and returns to 0 at 0.875 second.

The chart below indicates when the discrete blocks execute.

Blocks A and B execute independently of the enable control signal because they are not part of the enabled subsystem. When the enable control signal becomes positive, blocks C and D execute at their assigned sample rates until the enable control signal becomes zero again. Note that block C does not execute at 0.875 second when the enable control signal changes to zero.
Certain restrictions apply when you connect blocks with constant sample times (see Constant Sample Time) to the output port of a conditional subsystem.
An error appears when you connect a Model or S-Function block with constant sample time to the output port of a conditional subsystem.
The sample time of any built-in block with a constant sample time is converted to a different sample time, such as the fastest discrete rate in the conditional subsystem.
To avoid the error or conversion, either manually change the sample time of the block to a non-constant sample time or use a Signal Conversion block. The example below shows how to use the Signal Conversion block to avoid these errors.
Consider the following model m1.mdl.

The two Constant blocks in this model have constant sample times. When you simulate the model, the Simulink software converts the sample time of the Constant block inside the enabled subsystem to the rate of the Pulse Generator. If you simulate the model with sample time colors displayed (see Displaying Sample Time Colors), the Pulse Generator and Enabled Subsystem blocks are colored red. However, the Constant and Outport blocks outside of the enabled subsystem are colored magenta, indicating that these blocks still have a constant sample time.
Suppose the model above is referenced from a Model block inside an enabled subsystem, as shown below. (See Referencing a Model.)

An error appears when you try to simulate the top model, indicating that the second output of the Model block may not be wired directly to the enabled subsystem output port because it has a constant sample time. (See Referencing a Model.)
To avoid this error, insert a Signal Conversion block between the second output of the Model block and the enabled subsystem's Outport block.

This model simulates with no errors. With sample time colors displayed, the Model and Enabled Subsystem blocks are colored yellow, indicating that these are hybrid systems, that is, systems that contain multiple sample times.
![]() | About Conditional Subsystems | Triggered Subsystems | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |