Inheriting Sample Times

The sample times of a Model block are the sample times of the model that it references. If the referenced model needs to run at specific rates, the referenced model specifies the required rates. Otherwise, the referenced model inherits its sample time from the parent model.

Without the ability to inherit sample times, a Model block could not be placed in a triggered, function call, or iterator subsystem. 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, but could be reused with different sample times, for example, discrete at 0.1, discrete at 0.2, triggered, and so on.

A referenced model inherits its sample time if and only if all the following are true:

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, you must ensure that blocks connected to a referenced model with intrinsic samples times operate at the same rates as the referenced model.

If you want a Model block to be used in a model where it can inherit a sample time, you must constrain the solver declared for that model. On the Solver configuration pane, set solver Type to Fixed-step and Periodic sample time constraint to Ensure sample time independent.

To determine whether a referenced model inherits 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), first update some model that references it. Then select a Model block that references the referenced model and enter the following command at the MATLAB® command line:

get_param(gcb, 'CompiledSampleTime')

Blocks That Preclude Sample-Time Inheritance

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, including any S-Function blocks, whose outputs are functions of the inherited simulation time. If so, Simulink specifies a default sample time and displays an error if you have set the Periodic sample time constraint on the Solver configuration parameters dialog pane 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 their sample time and hence preclude a referenced model from inheriting its sample time from the parent model:

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 Writing S-Functions 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, you must not include S-functions in the referenced models that fail to declare whether their output depends on their inherited sample time. Simulink by default warns you if your model contains such blocks when you update or simulate the model. See Unspecified inheritability of sample time for details.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS