Clock
Display and provide simulation time
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
Calculate and Display Simulation Step Size using Memory and Clock Blocks
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
Port_1 — Sample time
scalar
Sample time, specified as the current simulation time at each simulation time step.
Data Types: double
Parameters
Display time — Display simulation time on block icon
off
(default) | on
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'
|
Decimation — Interval at which to update block icon
10
(default) | positive integer
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 |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Not recommended for production code. Relates to resource limits and restrictions on speed and memory often found in embedded systems. Generated code can contain dynamic allocation and freeing of memory, recursion, additional memory overhead, and widely-varying execution times. While the code is functionally valid and generally acceptable in resource-rich environments, smaller embedded targets often cannot support such code. Usually, blocks evolve toward being suitable for production code. Thus, blocks suitable for production code remain suitable.
Version History
Introduced before R2006a
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)