Specify Execution Domain
Execution domain specification allows you to set a model and its subsystems and referenced models to simulate as discrete-time or data-driven systems. Use this setting to separate the discrete dynamics from the rest of its dynamics, for example, in the design of a deployable controller for a plant that is modeled with continuous-time dynamics.
To simulate a computationally intensive signal processing or multirate signal processing system, you can also assign a dataflow domain. Dataflow domains simulate using a model of computation synchronous dataflow, which is data-driven and statically scheduled. For more information, see Dataflow Domain (DSP System Toolbox).
You can create subsystems that maintain their discrete execution domain irrespective of their environment. By constraining a subsystem to be discrete, you can increase reusability of your subsystem as a component. To improve code generation, this specification reduces unnecessary update methods, reduces major time step checks, and increases reusability of generated code.
Domain Specification Badge
The domain specification badge indicates the execution domain computed to a model or subsystem when you update the model diagram. You can toggle the visibility of the domain specification badge by turning on the Sample Time Display. For more information on visualizing sample time, see View Sample Time Information. The badge is visible at the bottom left corner of the Simulink® Editor.
The model below shows a discrete Sine Wave block whose rate is reduced by the Rate Transition block before driving the Gain block.
Observe that the model receives the Discrete execution domain because its contents are all discrete.
You can also toggle the visibility of the badge by enabling or disabling the Set Domain Specification parameter in the Execution tab of the Property Inspector.
Types of Execution Domains
You can instruct Simulink to assign the execution domain, along with the allowed sample times, via the Property Inspector.
Specification | Discrete | Other | Dataflow |
---|---|---|---|
Deduce from contents | X | X | - |
Discrete | X | - | - |
Dataflow | - | - | X |
Export function | X | - | - |
Deduce from contents
Let Simulink assign the execution domain based on the contents of the subsystem.Discrete
Constrain all blocks in a subsystem to be discrete.Dataflow
Simulate a computationally-intensive signal processing or multi-rate signal processing system. This setting requires the DSP System Toolbox™.Export function
Specify that the model is to be treated as an export-function model. When you specify a model as an export-function model, Simulink automatically sets the Solver selection in the Model Configuration Parameters toFixed-step
andauto
. See Export-Function Models Overview for more information.
When you update the model diagram or simulate the model, the badge displays the computed execution domain for the model component. There are three execution domains in Simulink:
Discrete Blocks have discrete states and sample times. Allowed samples times include Discrete Sample Times, Controllable Sample Time, and Asynchronous Sample Time.
Dataflow Dataflow domains simulate using computation synchronous dataflow, which is data-driven and statically scheduled. This execution domain requires the DSP System Toolbox. For more information, see Specifying Dataflow Domains (DSP System Toolbox).
Other Blocks are not strictly discrete.
Subsystems that receive the Other execution domain include:
Subsystems whose blocks have continuous states and sample times, including Continuous Sample Time, Fixed-in-Minor-Step Sample Time, and Variable Sample Time
Subsystems with a mixture of continuous and discrete sample times.
Subsystems with Asynchronous Sample Time.
If a subsystem has continuous, variable, fixed-in-minor step, Constant Sample Time, or a mixture of sample times, you can use the badge to enable or disable domain specification. The subsystem still receives the Other time domain.
The domain specification badge is not actionable when the currently selected subsystem or model is a linked block, inside a library block, or a conditionally executed subsystem that receives the Other domain. To change the execution domain of a linked library block, break the link to the parent library block. See Disable or Break Links to Library Blocks.
Set Execution Domain
You can set the domain specification per subsystem and at the root level of the model using the Execution tab of the Property Inspector. To enable the Property Inspector for the model, on the Modeling tab, under Design, click Property Inspector, or press Ctrl+Shift+I on your keyboard. On macOS, press command+option+O instead. If the domain specification badge is displayed, you can also open the Execution settings in the Property Inspector by clicking the badge. See Domain Specification Badge.
Select the Set Execution Domain check box. You can now specify the Domain.
Note
Changing the domain specification at the root level of the model does not change the setting for its child subsystems.
You can also enable this setting from the command line using set_param
to set the SetExecutionDomain
parameter 'on'
or
'off'
.
Once enabled, the default setting for the Domain parameter is
Deduce from contents
. When you update the diagram, the execution
domain is deduced from the characteristics of the blocks in the currently open subsystem. For
example, a system that has only discrete blocks is in the Discrete
execution domain. See Types of Execution Domains.
The badge shows the current specification setting. If you set the subsystem domain to
Deduce from contents
, the badge text displays
Deduce until you update the diagram. Once you update the model diagram,
the badge shows the computed execution domain, as described in Types of Execution Domains. When you enable
Set domain specification and Domain is set to
Deduce from Contents
, Simulink computes the execution domain of the currently focused subsystem based on the
blocks and sample times inside the subsystem.
To set the Domain parameter from the command line, use
set_param
to change ExecutionDomainType
to either
'Deduce'
or 'Discrete'
. You can also get the computed
execution domain after you update the diagram using the
CompiledExecutionDomain
parameter of the subsystem.
Enforce Discrete Execution Domain for a Subsystem
This example shows how to specify execution domains for the constituent subsystems of a model.
The SubsystemExecution
model has a discrete cruise controller subsystem that tracks the reference speed set in the Constant block named Desired Speed
. A car dynamics subsystem models the continuous-time dynamics of the car.
To visualize the sample times and domains of the subsystems, turn on the sample time colors and annotations.
The discrete cruise controller of the model has a hybrid sample time due to the presence of a continuous-time signal from the output of the car dynamics subsystem at the input port of the controller.
To enforce discrete-time execution of the controller:
Select the Subsystem block named
discrete cruise controller
.Open the Property Inspector and go to the Execution tab.
Select Set execution domain.
Set Domain to
Discrete
.
To update the sample time colors and annotations, update or simulate the model.
The discrete cruise controller subsystem is now discrete.
The car dynamics subsystem receives the hybrid sample time and the Other execution domain. To set the execution domain of the car dynamics subsystem to Deduce from Contents
:
Select the Subsystem block named
car dynamics
.Open the Property Inspector and go to the Execution tab.
Select Set execution domain.
Set Domain to
Deduce from contents
.
Optionally, set the Sample Time parameter of the Inport block in this subsystem to 0.
To update the sample time colors and annotations, update or simulate the model.
See Also
What Is Sample Time? | Sample Times in Subsystems | How Propagation Affects Inherited Sample Times | Dataflow Domain (DSP System Toolbox)