Main Content

Digital Clock

Output simulation time at specified sampling interval

  • Digital Clock block

Libraries:
Simulink / Sources

Description

The Digital Clock block outputs the simulation time only at the specified sampling interval. At other times, the block holds the output at the previous value. To control the precision of this block, use the Sample time parameter in the block dialog box.

Use this block rather than the Clock block, which outputs continuous time, when you need the current simulation time within a discrete system.

Examples

expand all

This example shows how to view the simulation sample time at a specified sampling interval using the Digital Clock block. In this model, the Scope shows the output of a Digital Clock block with the Sample time set to 0.2.

In this configuration, the Digital Clock block outputs the simulation time every 0.2 seconds. Otherwise, the block holds the output at the previous value.

Ports

Output

expand all

Sample time, in seconds, at the specified sampling interval. At other times, the block holds the output at the previous value.

Data Types: double

Parameters

expand all

Specify the sampling interval in seconds. You can specify the sampling interval in one of two ways:

  • As the period, specified as a real-valued scalar with data type double.

  • As the period and offset, specified as a real-valued vector of length 2 with data type double. The period and offset must be finite and non-negative, and the offset value must be less than the period.

For more information, see Specifying Sample Time.

Tip

Do not specify a continuous sample time, either 0 or [0,0]. Also, avoid specifying -1 (inheriting the sample time) because this block is a source.

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Values: scalar | vector
Default: '1'

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

See Also