| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
Ports & Subsystems
A Subsystem block represents a subsystem of the system that contains it. The Subsystem block can represent a virtual subsystem or a nonvirtual subsystem. The primary difference is that nonvirtual subsystems provide the ability to control when the contents of the subsystem are evaluated. Nonvirtual subsystems are executed as a single unit (atomic execution) by the Simulink engine. A subsystem is virtual unless the block is conditionally executed and/or you have selected the block Treat as atomic unit check box.
Tip To determine if a subsystem is virtual, use the get_param function to obtain the value of the IsSubsystemVirtual property for the block. This property returns a read-only boolean value for the block. See Block-Specific Parameters for the subsystem block that interests you. |
An Atomic Subsystem block is a Subsystem block that has its Treat as atomic unit parameter selected by default. You can create conditionally executed nonvirtual subsystems that are executed only when a transition occurs on a triggering, function-call, action, or enabling input (see Creating Conditional Subsystems).
You can create a subsystem in these ways:
Copy the Subsystem (or Atomic Subsystem) block from the Ports & Subsystems library into your model. You can then add blocks to the subsystem by opening the Subsystem block and copying blocks into its window.
Select the blocks and lines that are to make up the subsystem using a bounding box, then choose Create Subsystem from the Edit menu. Simulink software replaces the blocks with a Subsystem block. When you open the block, the window displays the blocks you selected, adding Inport and Outport blocks to reflect signals entering and leaving the subsystem.
The number of input ports drawn on the Subsystem block's icon corresponds to the number of Inport blocks in the subsystem. Similarly, the number of output ports drawn on the block corresponds to the number of Outport blocks in the subsystem.
See Creating Subsystems in the Simulink User's Guide for more information about subsystems.
See Inport for information on the data types accepted by a subsystem's input ports. See Outport for information on the data types output by a subsystem's output ports.

Cause Simulink software to display labels for the subsystem's ports on the subsystem's icon.
Default: FromPortIcon
Does not display port labels on the subsystem block.
If the corresponding port icon displays a signal name, display the signal name on the subsystem block. Otherwise, display the port block's name.
Display the name of the corresponding port block on the subsystem block.
If a name exists, display the name of the signal connected to the port on the subsystem block; otherwise, the name of the corresponding port block.
See Block-Specific Parameters for the command-line information.
Control user access to the contents of the subsystem.
Default: ReadWrite
Enables opening and modification of subsystem contents.
Enables opening but not modification of the subsystem. If the subsystem resides in a block library, you can create and open links to the subsystem and can make and modify local copies of the subsystem but cannot change the permissions or modify the contents of the original library instance.
Disables opening or modification of subsystem. If the subsystem resides in a library, you can create links to the subsystem in a model but cannot open, modify, change permissions, or create local copies of the subsystem.
See Block-Specific Parameters for the command-line information.
Enter name of a function to be called if an error occurs while Simulink software is executing the subsystem.
Default: ' '
Simulink software passes two arguments to the function: the handle of the subsystem and a string that specifies the error type. If no function is specified, Simulink software displays a generic error message if executing the subsystem causes an error.
See Block-Specific Parameters for the command-line information.
Specify whether to resolve names of workspace variables referenced by this subsystem.
Default: All
Resolve all names of workspace variables used by this subsystem, including those used to specify block parameter values and Simulink data objects (for example, Simulink.Signal objects).
Resolve only names of workspace variables used to specify block parameter values, data store memory (where no block exists), signals, and states marked as "must resolve".
Do not resolve any workspace variable names.
See Block-Specific Parameters for the command-line information.
Causes Simulink software to treat the subsystem as a unit when determining the execution order of block methods.
Default: Off
Cause Simulink software to treat the subsystem as a unit when determining the execution order of block methods. For example, when it needs to compute the output of the subsystem, Simulink software invokes the output methods of all the blocks in the subsystem before invoking the output methods of other blocks at the same level as the subsystem block.
Cause Simulink software to treat all blocks in the subsystem as being at the same level in the model hierarchy as the subsystem when determining block method execution order. This can cause execution of methods of blocks in the subsystem to be interleaved with execution of methods of blocks outside the subsystem.
This parameter enables:
Minimize algebraic loop occurrences.
Sample time
Real-Time Workshop system code (requires a Real-Time Workshop license)
See Block-Specific Parameters for the command-line information.
Try to eliminate any algebraic loops that include the subsystem.
Default: Off
Try to eliminate any algebraic loops that include the subsystem.
Does not try to eliminate any algebraic loops that include the subsystem.
Treat as atomic unit enables this parameter.
See Block-Specific Parameters for the command-line information.
Enable execution context propagation across the boundary of this subsystem.
Default: Off
Enables execution context propagation across this subsystem's boundary.
Does not enable execution context propagation across this subsystem's boundary.
Conditional execution of the subsystem enables this parameter.
See Block-Specific Parameters for the command-line information.
Simulink software displays a warning if it has to compute any of this function-call subsystem's inputs directly or indirectly during execution of a function-call.
Default: Off
Simulink software displays a warning if it has to compute any of this function-call subsystem's inputs directly or indirectly during execution of a function-call.
Simulink software does not display a warning if it has to compute any of this function-call subsystem's inputs directly or indirectly during execution of a function-call.
Use of a function-call subsystem enables this parameter.
The option is effective only if the Context-dependent inputs diagnostic on the Configuration Parameters > Connectivity dialog box is set to Use local settings.
See Block-Specific Parameters for the command-line information.
Specify whether all blocks in this subsystem must run at the same rate or can run at different rates.
Default: -1
-1
Specify the inherited sample time. Use this sample time if the blocks in the subsystem can run at different rates.
inf
Specify constant sample time
[Ts 0]
Specify periodic sample time.
If the blocks in the subsystem can run at different rates, specify the subsystem's sample time as inherited (-1).
If all blocks must run at the same rate, specify the sample time corresponding to this rate as the value of the subsystem's Sample time parameter.
If any of the blocks in the subsystem specify a different sample time (other than -1 or inf), Simulink software displays an error message when you update or simulate the model. For example, suppose all the blocks in the subsystem must run 5 times a second. To ensure this, specify the sample time of the subsystem as 0.2. In this example, if any of the blocks in the subsystem specify a sample time other than 0.2, -1, or inf, Simulink software displays an error when you update or simulate the model.
Treat as atomic unit enables this parameter.
See Block-Specific Parameters for the command-line information.
Specify the code format to be generated for an atomic (nonvirtual) subsystem.
Default: Auto
Real-Time Workshop software chooses the optimal format for you based on the type and number of instances of the subsystem that exist in the model.
Real-Time Workshop software inlines the subsystem unconditionally.
Real-Time Workshop software generates a separate, non-reentrant function with no arguments, and optionally place the subsystem code in a separate file.
Real-Time Workshop software generates a function with arguments that allows the subsystem's code to be shared by other instances of it in the model.
If you select Reusable function while your generated code is under source control, set Real-Time Workshop file name options to Use subsystem name, Use function name, or User specified. Otherwise, the names of your code files change whenever you modify your model, which prevents source control on your files.
This parameter requires a Real-Time Workshop license.
Treat as atomic unit enables this parameter.
Setting this parameter to Function or Reusable function enables the following parameters:
Real-Time Workshop function name options
Real-Time Workshop file name options
Function with separate data (requires a Real-Time Workshop Embedded Coder license and an ERT-based system target file)
Memory section for initialize/terminate functions (requires a Real-Time Workshop Embedded Coder license and an ERT-based system target file)
Memory section for execution functions (requires a Real-Time Workshop Embedded Coder license and an ERT-based system target file)
See Block-Specific Parameters for the command-line information.
Specify how Real-Time Workshop software is to name the function it generates for the subsystem.
Default: Auto
Assign a unique function name using the default naming convention, model, _subsystem(), where model is the name of the model and subsystem is the name of the subsystem (or that of an identical one when code is being reused).
Use the subsystem name as the function name.
Assign a unique, valid C or C++ function name that you specify.
If you specify Use subsystem name and the subsystem is a library block, Real-Time Workshop software names the function (and filename) with the name of the library block, regardless of the names used for that subsystem in the model.
This parameter requires a Real-Time Workshop license.
Selecting User specified enables the Real-Time Workshop function name option parameter.
Treat as atomic unit enables this parameter.
See Block-Specific Parameters for the command-line information.
Specify a unique, valid C or C++ function name for subsystem code.
Default: ' '
Use this parameter if you want to give the function a specific name instead of allowing the Real-Time Workshop code generator to assign its own autogenerated name or use the subsystem name.
Setting Real-Time Workshop function name options to User specified enables this parameter.
See Block-Specific Parameters for the command-line information.
Specify how Real-Time Workshop software is to name the separate file for the function it generates for the subsystem.
Default: Auto
Generate the function code within the module generated from the subsystem's parent system, or, if the subsystem's parent is the model itself, within the file model.c or model.cpp
Generate a separate file and name it with the name of the subsystem or library block
Generate a separate file and name it with the function name you specify for Real-Time Workshop function name options
Assign a unique, valid C or C++ function name that you specify
If you specify Use subsystem name, the subsystem filename is mangled if the model contains Model blocks, or if a model reference target is being generated for the model. In these situations, the filename for the subsystem consists of the subsystem name prefixed by the model name.
This parameter requires a Real-Time Workshop license.
Setting this parameter to User specified enables the Real-Time Workshop filename (no extension) parameter.
See Block-Specific Parameters for the command-line information.
Specify how Real-Time Workshop software is to name the file for the function it generates for the subsystem.
Default: ' '
The filename that you specify does not have to be unique. However, avoid giving non-unique names that result in cyclic dependencies (for example, sys_a.h includes sys_b.h, sys_b.h includes sys_c.h, and sys_c.h includes sys_a.h).
This parameter requires a Real-Time Workshop license.
Setting Real-Time Workshop file name options to User specified enables this parameter.
See Block-Specific Parameters for the command-line information.
Generate subsystem function code in which the internal data for an atomic subsystem is separated from its parent model and is owned by the subsystem.
Default: Off
Generate subsystem function code in which the internal data for an atomic subsystem is separated from its parent model and is owned by the subsystem. As a result, the generated code for the atomic subsystem is easier to trace and test. The data separation also tends to reduce the size of data structures throughout the model.
Do not generate subsystem function code in which the internal data for an atomic subsystem is separated from its parent model and is owned by the subsystem.
This parameter requires a Real-Time Workshop Embedded Coder license and an ERT-based system target file.
Setting Real-Time Workshop system code to Function enables this parameter.
Selecting this check box enables these parameters:
Memory section for constants
Memory section for internal data
Memory section for parameters
See Block-Specific Parameters for the command-line information.
Indicate how the Real-Time Workshop Embedded Coder software is to apply memory sections to the subsystem's initialization and termination functions.
Default: Inherit from model
Apply the root model's memory sections to the subsystem's function code
Not apply memory sections to the subsystem's system code, overriding any model-level specification
Apply one of the model's memory sections to the subsystem
The possible values vary depending on what (if any) package of memory sections you have set for the model's configuration. See Inserting Comments and Pragmas in Generated Code, Configuring Memory Sections, and Real-Time Workshop Pane: Memory Sections in the Real-Time Workshop Embedded Coder documentation.
If you have not configured the model with a package, Inherit from model is the only value that appears. Otherwise, the list includes Default and all memory sections the model's package contains.
These options can be useful for overriding the model's memory section settings for the given subsystem.
This parameter requires a Real-Time Workshop Embedded Coder license and an ERT-based system target file.
Setting Real-Time Workshop system code to Function enables this parameter.
See Block-Specific Parameters for the command-line information.
Indicate how the Real-Time Workshop Embedded Coder software is to apply memory sections to the subsystem's execution functions.
Default: Inherit from model
Apply the root model's memory sections to the subsystem's function code
Not apply memory sections to the subsystem's system code, overriding any model-level specification
Apply one of the model's memory sections to the subsystem
The possible values vary depending on what (if any) package of memory sections you have set for the model's configuration. See Inserting Comments and Pragmas in Generated Code, Configuring Memory Sections, and Real-Time Workshop Pane: Memory Sections in the Real-Time Workshop Embedded Coder documentation.
If you have not configured the model with a package, Inherit from model is the only value that appears. Otherwise, the list includes Default and all memory sections the model's package contains.
These options can be useful for overriding the model's memory section settings for the given subsystem.
This parameter requires a Real-Time Workshop Embedded Coder license and an ERT-based system target file.
Setting Real-Time Workshop system code to Function enables this parameter.
See Block-Specific Parameters for the command-line information.
Indicate how the Real-Time Workshop Embedded Coder software is to apply memory sections to the subsystem's data.
Default: Inherit from model
Apply the root model's memory sections to the subsystem's data
Not apply memory sections to the subsystem's data, overriding any model-level specification
Apply one of the model's memory sections to the subsystem
Can be useful for overriding the model's memory section settings for the given subsystem.
The possible values vary depending on what (if any) package of memory sections you have set for the model's configuration. See Configuring Memory Sections in the Real-Time Workshop Embedded Coder User's Guide.
If you have not configured the model with a package, Inherit from model is the only value that appears. Otherwise, the list includes Default and all memory sections the model's package contains.
This parameter requires a Real-Time Workshop Embedded Coder license and an ERT-based system target file.
Setting Real-Time Workshop system code to Function and selecting the Function with separate data check box enables this parameter.
See Block-Specific Parameters for the command-line information.
Indicate how the Real-Time Workshop Embedded Coder software is to apply memory sections to the subsystem's data.
Default: Inherit from model
Apply the root model's memory sections to the subsystem's data
Not apply memory sections to the subsystem's data, overriding any model-level specification
Apply one of the model's memory sections to the subsystem
Can be useful for overriding the model's memory section settings for the given subsystem.
The possible values vary depending on what (if any) package of memory sections you have set for the model's configuration. See Configuring Memory Sections in the Real-Time Workshop Embedded Coder User's Guide.
If you have not configured the model with a package, Inherit from model is the only value that appears. Otherwise, the list includes Default and all memory sections the model's package contains.
This parameter requires a Real-Time Workshop Embedded Coder license and an ERT-based system target file.
Setting Real-Time Workshop system code to Function and selecting the Function with separate data check box enables this parameter.
See Block-Specific Parameters for the command-line information.
Indicate how the Real-Time Workshop Embedded Coder software is to apply memory sections to the subsystem's data.
Default: Inherit from model
Apply the root model's memory sections to the subsystem's function code
Not apply memory sections to the subsystem's system code, overriding any model-level specification
Apply one of the model's memory sections to the subsystem
Can be useful for overriding the model's memory section settings for the given subsystem.
The possible values vary depending on what (if any) package of memory sections you have set for the model's configuration. See Configuring Memory Sections in the Real-Time Workshop Embedded Coder User's Guide.
If you have not configured the model with a package, Inherit from model is the only value that appears. Otherwise, the list includes Default and all memory sections the model's package contains.
This parameter requires a Real-Time Workshop Embedded Coder license and an ERT-based system target file.
Setting Real-Time Workshop system code to Function and selecting the Function with separate data check box enables this parameter.
See Block-Specific Parameters for the command-line information.
Sample Time | Depends on the blocks in the subsystem |
Dimensionalized | Depends on the blocks in the subsystem |
Multidimensionalized | Depends on the blocks in the subsystem |
Virtual | Yes, if the read-only property IsSubsystemVirtual is on |
Zero Crossing | Yes, for enable and trigger ports if present |
![]() | Stop Simulation | Sum, Add, Subtract, Sum of Elements | ![]() |

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 |