Main Content

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.

SpecificationDiscreteOtherDataflow
Deduce from contentsXX-
DiscreteX--
Dataflow--X
Export functionX--

  • 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 model badgeExport 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 to Fixed-step and auto. 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:

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:

  1. Select the Subsystem block named discrete cruise controller.

  2. Open the Property Inspector and go to the Execution tab.

  3. Select Set execution domain.

  4. 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:

  1. Select the Subsystem block named car dynamics.

  2. Open the Property Inspector and go to the Execution tab.

  3. Select Set execution domain.

  4. 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

| | | (DSP System Toolbox)