## How Propagation Affects Inherited Sample Times

During a model update, for example at the beginning of a simulation, Simulink® uses a process called sample time propagation to determine the sample times of blocks that inherit their sample times. The figure below illustrates a Discrete Filter block with a sample time period `Ts` driving a Gain block.

Because the output of the Gain block is the input multiplied by a constant, its output changes at the same rate as the filter. In other words, the Gain block has an effective sample rate equal to the sample rate of the filter. The establishment of such effective rates is the fundamental mechanism behind sample time propagation in Simulink.

### Process for Sample Time Propagation

Simulink uses the following basic process to assign sample times to blocks that inherit their sample times:

1. Propagate known sample time information forward.

2. Propagate known sample time information backward.

3. Apply a set of heuristics to determine additional sample times.

4. Repeat until all sample times are known.

### Simulink Rules for Assigning Sample Times

A block having a block-based sample time inherits a sample time based on the sample times of the blocks connected to its inputs, and in accordance with the following rules:

RuleAction
All of the inputs have the same sample time and the block can accept that sample timeSimulink assigns the sample time to the block
The inputs have different discrete sample times and all of the input sample times are integer multiples of the fastest input sample timeSimulink assigns the sample time of the fastest input to the block . (This assignment assumes that the block can accept the fastest sample time.)
The inputs have different discrete sample times, some of the input sample times are not integer multiples of the fastest sample time, and the model uses a variable-step solverSimulink assigns a fixed-in-minor-step sample time to the block.
The inputs have different discrete sample times, some of the input sample times are not integer multiples of the fastest sample time, the model uses a fixed-step solver, and Simulink can compute the greatest common integer divisor (GCD) of the sample times coming into the blockSimulink assigns the GCD sample time to the block. Otherwise, Simulink assigns the fixed step size of the model to the block.
The sample times of some of the inputs are unknown, or if the block cannot accept the sample timeSimulink determines a sample time for the block based on a set of heuristics.

### Backpropagation in Sample Times

When you update or simulate a model that specifies the sample time of a source block as inherited (–1), the sample time of the source block may be backpropagated; Simulink may set the sample time of the source block to be identical to the sample time specified by or inherited by the block connected to the source block. For example, in the model below, the Simulink software recognizes that the Sine Wave block is driving a Discrete-Time Integrator block whose sample time is `1`; so it assigns the Sine Wave block a sample time of `1`.

You can verify this sample time setting by selecting Information Overlays > Colors from the Debug tab of the Simulink toolstrip and noting that both blocks are red. Because the Discrete-Time Integrator block looks at its input only during its sample hit times, this change does not affect the results of the simulation, but does improve the simulation performance.

Now replacing the Discrete-Time Integrator block with a continuous Integrator block, as shown in the model below, causes the Sine Wave and Gain blocks to change to continuous blocks. You can test this change by, on the Modeling tab, selecting Update Model to update the colors. Both blocks now appear black.

Note

Backpropagation makes the sample times of model sources dependent on block connectivity. If you change the connectivity of a model whose sources inherit sample times, you can inadvertently change the source sample times. For this reason, when you update or simulate a model, by default, Simulink displays warnings at the command line if the model contains sources that inherit their sample times. See Source block specifies -1 sample time for more information.