Main Content

Clock

Display and provide simulation time

  • Clock block

Libraries:
Simulink / Sources

Description

The Clock block outputs the current simulation time at each simulation step. This block is useful for other blocks that need the simulation time.

When you need the current time within a discrete system, use the Digital Clock block.

Examples

expand all

This example shows how to use the Memory and Clock blocks to calculate and display the step size in a simulation. The Sum block subtracts the time at the previous time step, which the Memory block generates, from the current time, which the Clock block generates.

Because Inherit sample time is not selected for the Memory block, the block sample time depends on the type of solver for simulating the model. In this case, the model uses a fixed-step solver. Therefore, the sample time of the Memory block is the solver step size, or 1.

If you replace the Memory block with a Unit Delay block, you get the same results. The Unit Delay block inherits a discrete sample time of 1.

Extended Examples

Ports

Output

expand all

Sample time, specified as the current simulation time at each simulation time step.

Data Types: double

Parameters

expand all

Select this check box to display the simulation time as part of the Clock block icon. When you clear this check box, the simulation time does not appear on the block icon.

Programmatic Use

Block Parameter: DisplayTime
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Specify the interval at which Simulink® updates the Clock icon as a positive integer.

Suppose that the decimation is 1000. For a fixed integration step of 1 millisecond, the Clock icon updates at 1 second, 2 seconds, and so on.

Dependencies

To display the simulation time on the block icon, you must select the Display time check box.

Programmatic Use

Block Parameter: Decimation
Type: character vector
Value: scalar
Default: '10'

Block Characteristics

Data Types

double

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

Version History

Introduced before R2006a