Unit Delay
Retain an input value and output it on the next execution.
Description
Unit Delay outputs the input value from its preceding execution. On the first execution after initialization, it outputs the configured initial condition.
The delay is measured in executions of the block. With periodic execution every 10 milliseconds, one delay represents 10 milliseconds. With event activation, it represents the interval between consecutive activations, which need not be constant.
The figure illustrates the sequence for a scalar signal with an initial condition of zero.
Behavior
Let u[k] be the input at execution k, and let y[k] be the output. The first execution is k = 0.
| Execution | Output |
|---|---|
k = 0 |
Initial condition |
k > 0 |
u[k − 1] |
After reinitializing the model, the first output is again the configured initial condition.
Unit Delay has state and no direct feedthrough. Its output depends on the preceding input value, with the initial condition supplying the first output. See State and direct feedthrough.
Ports
| Direction | Count | Signal |
|---|---|---|
| Input | One | The value to retain for the next execution |
| Output | One | The previously retained value, or the initial condition on the first execution |
The output preserves the input’s data type and shape. A vector or matrix is delayed as a complete value, with each element retaining its position in the array.
Parameters
Initial condition
| Property | Value |
|---|---|
| Default | 0.0 |
| Meaning | Starting value for the output |
| First output | The configured initial condition |
The initial condition must be valid for the signal’s data type and shape. For a numeric scalar, specify a representable numeric value. A parameter reference can be used when the initial condition is defined in the model’s data declarations. See Parameters.
Changing the initial condition changes the response after initialization.
Example
The Moving Average model uses two Unit Delay blocks in sequence. The first supplies the previous input sample, and the second supplies the input from two executions earlier. A Sum combines these with the current input, and division by three produces the average.
Both delays start at zero. For an initial input of one, the first average is one third. The first three executions progressively fill the averaging window.
Open Moving Average in ModeloopThe Quickstart describes the included scenario and expected response.
Related topics
Blocks explains ports and parameters. Signals describes signal types and shapes. Simulation describes configuring and running a model.