Using Simulink Previous page   Next Page

Model Block 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's simulation target specifies the required rates. Otherwise, the target specifies that the referenced model inherits its sample time from the parent model. Specifically, a referenced model inherits its sample time if all the following conditions 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 for an iterator subsystem. Further, 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.

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 (see Periodic sample time constraint). If the model is unable to inherit sample times, this setting causes Simulink to display an error message when generating the referenced model's simulation (or Real-Time Workshop) target. To determine the intrinsic sample time of a referenced model (or the fastest intrinsic sample time for multirate referenced models), first update a model that references it. Then select a Model block that references the referenced model and enter the following command at the MATLAB command line:

Blocks That Preclude Sample-Time Inheritance

Using a block whose output depends on an inherited sample time in a referenced model can cause a simulation to produce unexpected or erroneous results. For this reason, when building a simulation target for a model 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 generates a simulation target that 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).

The outputs of the following built-in blocks depend on their inherited 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). Thus, to avoid simulation errors with referenced models that inherit their sample time, you need to take care not to 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).


Previous page  Using Model Arguments Referenced Model I/O Next page

© 1994-2005 The MathWorks, Inc.