Sample Times in Subsystems
R2026bSubsystems fall into two categories: triggered and non-triggered. For triggered
subsystems, in general, the subsystem gets its sample time from the triggering signal.
One exception occurs when you use a Trigger block to create a triggered subsystem. If you set the block
Trigger type to function-call
and the Sample time type to
periodic, the SampleTime parameter
becomes active. In this case, you specify the sample time of the
Trigger block, which in turn, establishes the sample time of the
subsystem.
There are four non-triggered subsystems:
Virtual
Enabled
Atomic
Action
Simulink® calculates the sample times of virtual and enabled subsystems based on the respective sample times of their contents.
The atomic subsystem is a special case in that the subsystem block has a
SystemSampleTime parameter. Moreover, for a sample time other
than the default value of –1, the blocks inside the atomic subsystem can have only a
value of Inf, –1, or the identical (discrete) value of the subsystem
SampleTime parameter. If the atomic subsystem is left as
inherited, the software calculates the block sample time in the same manner as the
virtual and enabled subsystems. However, the main purpose of the subsystem
SampleTime parameter is to allow for the simultaneous
specification of a large number of blocks within an atomic subsystem that are all set to
inherited. To obtain the sample time set on an atomic subsystem, use this
command:
st = get_param(atomicSubsystemBlock,"SystemSampleTime");
Finally, the sample time of the action subsystem is set by the If block or the Switch Case block.
For non-triggered subsystems where blocks have different sample times, get the compiled sample time of the subsystem. The software returns the compiled sample time of the subsystem as a cell array of all the sample times present in the subsystem. To get the compiled sample time, use this command:
cst = get_param(subsystemBlock,"CompiledSampleTime");