The sample time of a block is a parameter that indicates when the block produces an
output, and eventually updates its internal state. To specify sample time for a
MATLAB® System block, implement the
getSampleTimeImpl method with a call to
createSampleTime. To query the MATLAB System block for current sample time and simulation time, use the
getCurrentTime methods. For more information, see Specify Sample Time for MATLAB System Block System Objects.
If you use discrete sample time in simulation,
Simulink® only calculates the output of a simulation for each of the fixed time
intervals. To specify discrete sample time, in the
'Discrete' and set the
When the sample time is inherited, Simulink determines the best sample time for the block based on the block's
role within the model. To specify inherited sample time, in the
'Inherited'. When using inherited
sample time, you can alter or error out on specific sample times by specifying the
'ErrorOnPropagation' Name-Value pair.
In fixed-in-minor-step sample time,
Simulink does not execute the block at the minor time steps, the updates only
occur at the major time steps. To specify the fixed-in-minor time step, in the
'Fixed In Minor Step'.
To use controllable sample time, configure a block to specify controllable sample time with a resolution Tbase, where Tbase is the smallest allowable time interval between block executions. A block using controllable sample time can be dynamically set to execute at n multiples of Tbase, then the block's next execution is
Tnext = n Tbase + T
To specify Tbase in MATLAB System block, in the
'Controllable' and set the
'TickTime' property to Tbase. You can set the n in your MATLAB System block using
For more information on types of sample time, see Types of Sample Time. To see an example on how to control the sample time of the MATLAB System block using System object™ methods, see Specify Sample Time for MATLAB System Block System Objects.