|On this page…|
The sample times of a Model block are the sample times of the model that it references. If the referenced model must run at specific rates, the model specifies the required rates. Otherwise, the referenced model inherits its sample time from the parent model.
Placing a Model block in a triggered, function call, or iterator subsystem relies on the ability to inherit sample times. Additionally, allowing a Model block to inherit sample time maximizes its reuse potential. For example, a model might fix the data types and dimensions of all its input and output signals. You could reuse the model with different sample times (for example, discrete at 0.1 or discrete at 0.2, triggered, and so on).
A referenced model inherits its sample time if the model:
Does not have any continuous states
Specifies a fixed-step solver and the Fixed-step size is auto
Contains no blocks that specify sample times (other than inherited or constant)
Does not contain any S-functions that use their specific sample time internally
Has only one sample time (not counting constant and triggered sample time) after sample time propagation
Does not contain any blocks, including Stateflow® charts, that use absolute time, as listed in Blocks That Depend on Absolute Time
Does not contain any blocks whose outputs depend on inherited sample time, as listed in Blocks Whose Outputs Depend on Inherited Sample Time.
You can use a referenced model that inherits its sample time anywhere in a parent model. By contrast, you cannot use a referenced model that has intrinsic sample times in a triggered, function call, or iterator subsystem. To avoid rate transition errors, ensure that blocks connected to a referenced model with intrinsic samples times operate at the same rates as the referenced model.
To determine whether a referenced model can inherit its sample time, set the Periodic sample time constraint on the Solver configuration parameters dialog pane to Ensure sample time independent. If the model is unable to inherit sample times, this setting causes Simulink® to display an error message when building the model. See Periodic sample time constraint for more about this option.
To determine the intrinsic sample time of a referenced model, or the fastest intrinsic sample time for multirate referenced models:
Update the model that references the model
Select a Model block within the parent model
Enter the following at the MATLAB® command line:
The following Simulink blocks depend on absolute time, and therefore preclude a referenced model from inheriting sample time:
Backlash (only when the model uses a variable-step solver and the block uses a continuous sample time)
Discrete-Time Integrator (only when used in triggered subsystems)
Sine Wave (only when the Sine type parameter is Time-based)
Stateflow (only when the chart uses the reserved word t to reference time)
To Workspace (only when logging to Timeseries or Structure With Time format)
Some blocks other than Simulink blocks depend on absolute time. See the documentation for the blocksets that you use.
Using a block whose output depends on an inherited sample time in a referenced model can cause simulation to produce unexpected or erroneous results. For this reason, when building a submodel that does not need to run at a specified rate, Simulink checks whether the model contains any blocks whose outputs are functions of the inherited simulation time. This includes checking S-Function blocks. If Simulink finds any such blocks, it specifies a default sample time. Simulink displays an error if you have set the Configuration Parameters > Solver > Periodic sample time constraint to Ensure sample time independent. See Periodic sample time constraint for more about this option.
The outputs of the following built-in blocks depend on inherited sample time. The outputs of these blocks preclude a referenced model from inheriting its sample time from the parent model:
From Workspace (if it has input data that contains time)
Probe (if probing sample time)
Simulink assumes that the output of an S-function does not depend on inherited sample time unless the S-function explicitly declares the contrary. See Sample Times for information on how to create S-functions that declare whether their output depends on their inherited sample time.
To avoid simulation errors with referenced models that inherit their sample time, do not include S-functions in the referenced models that fail to declare whether their output depends on their inherited sample time. By default, Simulink warns you if your model contains such blocks when you update or simulate the model. See Unspecified inheritability of sample time for details.