| Using Simulink | ![]() |
Constant Sample Time
A block whose whose output cannot change from its initial value during a simulation is said to have constant sample time. A block has constant sample time if it satisfies both of the following conditions:
inf) or its sample time is declared to be inherited and it inherits a constant sample time from another block to which it is connected.
When Simulink updates a model, for example, at the beginning of a simulation, Simulink determines which blocks, if any, have constant sample time, and computes the initial values of the output ports. During the simulation, Simulink uses the initial values whenever the outputs of blocks with constant sample time are required, thus avoiding unnecessary computations.
You can determine which blocks have constant sample time by selecting Sample Time Colors from the Format menu and updating the model. Blocks with constant sample time are colored magenta.
For example, in this model, as sample time colors show, both the Constant and Gain blocks have constant sample time.
The Gain block has constant sample time because it inherits its sample time from the Constant block and all of the model's parameters are inlined, i.e., nontunable.
| Note The Simulink block library includes a few blocks, e.g., the S-Function, Level-2 M-File S-Function, Rate Transition, and Model block, whose ports can produce outputs at different sample rates. It is possible for some of the ports of such blocks to inherit a constant sample time. The ports with constant sample time produce output only once, at the beginning of the simulation. The other ports produce outputs at their sample rates. |
How Simulink Treats Blocks with Infinite Sample Times and Tunable Parameters
A block that has tunable parameters cannot have constant sample time even if its sample time is specified to be infinite. This is because the fact that a block has one or more tunable parameters means that you can change the values of its parameters during simulation and hence the value of its outputs. In this case, Simulink uses sample time propagation (see Sample Time Propagation) to determine the block's actual sample time.
For example, consider the following model.
In this example, although the Constant block's sample time is specified to be infinite, it cannot have constant sample time because the inlined parameters option is off for this model and therefore the block's Constant value parameter is tunable. Since the Constant block's output can change during the simulation, Simulink has to determine a sample time for the block that ensures accurate simulation results. It does this by treating the Constant block's sample time as inherited and using sample time propagation to determine its sample time. The first nonvirtual block in the diagram branch to which the Constant block is connected is the Discrete-Time Integrator block. As a result, the block inherits its sample time (1 sec) via back propagation from the Discrete-Time Integrator block.
| Sample Time Propagation | Mixed Continuous and Discrete Systems | ![]() |
© 1994-2005 The MathWorks, Inc.