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 modelmodel 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 Sample Time > Colors from the Simulink Display menu 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 modelmodel below, causes the Sine Wave and Gain blocks to change to continuous blocks. You can test this change by selecting Simulation > Update Diagram 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.

Was this topic helpful?