Main Content

Types of Sample Time

Discrete Sample Time

Given a block with a discrete sample time, Simulink® executes the block output or update method at times


where the sample time period Ts is always greater than zero and less than the simulation time Tsim. The number of periods (n) is an integer that must satisfy


As simulation progresses, Simulink computes block outputs only once at each of these fixed time intervals of tn. These simulation times at which Simulink executes the output method of a block for a given sample time are called sample time hits. Discrete sample times are the only type for which sample time hits are known a priori.

If you need to delay the initial sample hit time, you can define an offset, To.

The Unit Delay block is an example of a block with a discrete sample time.

Continuous Sample Time

Continuous sample time hits are divided into major time steps and minor time steps. Minor time steps are subdivisions of the major time steps. The solver produces a result at each major time step. The solver uses results at the minor time steps to improve the accuracy of the result at the major time step.

The ODE solver you choose integrates all continuous states from the simulation start time to a given major or minor time step. The solver determines the times of the minor steps and uses the results at the minor time steps to improve the accuracy of the results at the major time steps. You see the block output only at the major time steps.

To specify continuous sample time for a block, such as the Derivative block, for the Sample time parameter, enter [0, 0] or 0.

Inherited Sample Time

If a block sample time is set to [–1 0] or –1, the sample time is inherited, and Simulink determines the best sample time for the block based on the context of the block within the model. Simulink determines the sample time for blocks with inherited sample time during compilation. Because the inherited setting is overwritten in compilation, the Sample Time Legend never shows inherited sample time [-1 0] in a compiled model. For more information, see View Sample Time Information.

Some blocks inherit sample time by default. For these blocks, the parameter is not visible unless you specify a noninherited value. For example, the Gain and Rounding Function blocks do not have a visible sample time parameter and have inherited sample time by default. As a best practice, do not change the Sample time parameter for these blocks. For more information, see Blocks for Which Sample Time Is Not Recommended.

All inherited blocks are subject to the process of sample time propagation. For more information, see How Propagation Affects Inherited Sample Times.


If the sample time of a block is [0 1], the block has fixed-in-minor-step sample time. For this sample time, the block does not execute at the minor time steps. The block executes only at major time steps. Fixed-in-minor-step sample time eliminates unnecessary computations of blocks with outputs that cannot change between major steps.

While you can explicitly set a block to fixed-in-minor-step sample time, more often the software sets this condition as either an inherited sample time or as an alteration to a specification of continuous sample time. Fixed-in-minor-step sample time is equivalent to the fastest discrete rate in a system that uses a fixed-step solver. When you use a fixed-step solver, fixed-in-minor-step sample time is converted to the fastest discrete sample time.

Constant Sample Time

In Simulink, a constant is a symbolic name or expression whose value you can change only outside the algorithm or through supervisory control. Blocks whose outputs do not change during normal execution of the model, such as the Constant block, are always considered to be constant.

Simulink assigns constant sample time to these blocks. They run the block output method:

  • At the start of a simulation

  • In response to runtime changes in the environment, such as tuning a parameter

For constant sample time, the block sample time assignment is [inf 0] or inf.

For a block to allow constant sample time, the block must not have continuous or discrete states and must not drive an output port of a conditionally executed subsystem. For more information, see Using Enabled Subsystems.

The Simulink block library includes several blocks whose ports can produce outputs at different sample rates, such as the MATLAB S-Function block, the Level-2 MATLAB S-Function block, and the C S-Function block. Some ports of these blocks can have a constant sample time.

Variable Sample Time

Blocks that use a variable sample time have an implicit sample time parameter that the block specifies. The block tells the software when it executes. The compiled sample time is [–2 Tvo], where Tvo is a unique variable offset.

The Hit Scheduler block and the Pulse Generator block both have variable sample time. Variable sample time is supported only for variable-step solvers. The Hit Scheduler block is not supported for fixed-step solvers. When you use a fixed-step solver to simulate a model that contains a Pulse Generator block, the block specifies a discrete sample time.

To learn how to write your own block that uses a variable sample time, see C MEX S-Function Examples.

Controllable Sample Time

You can configure a block to use a controllable sample time with a resolution Tbase. Tbase is the smallest allowable time interval between block executions. To set Tbase in your own C S-Function block, use the ssSetControllableSampleTime function.

When a block uses controllable sample time, you can dynamically configure the block to execute at n multiples of Tbase. The time of the next block execution is

Tnext = n Tbase + T

You can set n in your C S-Function block using the ssSetNumTicksToNextHitForControllableSampleTime function.

Triggered Sample Time

If a block is inside a triggered subsystem, such as a function-call- or enabled subsystem, the block may be constant or have a triggered sample time, except in the case of an asynchronous function call. You cannot specify the triggered sample time type explicitly. To achieve a triggered sample time during compilation, set the block sample time to inherited (–1). The software then determines the specific times at which the block executes during simulation.

Asynchronous Sample Time

An asynchronous sample time is similar to a triggered sample time. In both cases, you need to specify an inherited sample time because the Simulink engine does not regularly execute the block. Instead, a runtime condition determines when the block executes. For an asynchronous sample time, an S-function makes an asynchronous function call.

The differences between these sample time types are:

  • Only a function-call subsystem can have an asynchronous sample time. See Using Function-Call Subsystems.

  • The source of the function-call signal is an S-function that has the option SS_OPTION_ASYNCHRONOUS.

  • The asynchronous sample time can also occur when a virtual block is connected to an asynchronous S-function or an asynchronous function-call subsystem.

  • The asynchronous sample time is important to certain code generation applications. See Asynchronous Events (Simulink Coder).

  • The sample time is [1,n].

For an explanation of how to use blocks to model and generate code for asynchronous event handling, see Rate Transitions and Asynchronous Blocks (Simulink Coder).

Related Topics