| Contents | Index |
Discrete
The Delay block supports:
Variable delay length
Specification of the initial condition from an input port
Resetting the state to the initial condition with an external reset signal
State storage
Using a circular buffer instead of an array buffer for state storage
The Delay block delays an input u according to the Delay length parameter, which you specify on the dialog box, or a delay length that a signal supplies to the d input port. The initial block output depends on the Initial condition parameter, which you specify on the dialog box, or an initial condition that a signal supplies to the x0 input port. Whether or not the block output resets to the initial condition depends on the External reset parameter, which you specify on the dialog box.
The following dimensional requirements apply:
Delay length and External reset must be scalar.
Initial condition can be scalar or nonscalar.
For frame-based processing, signal dimensions of the data input port u cannot be larger than two.
The icon changes depending on the number of block inputs.
| Icon | Number of Inputs |
|---|---|
| One:
|
| Two:
|
| Three:
|
| Four:
|
The block supports input signals of the following data types:
| Input Signal | Supported Data Types |
|---|---|
| u |
|
| d |
|
| x0 |
|
When u is Boolean, x0 must be Boolean. When u uses an enumerated type, x0 must use the same enumerated type. Otherwise, x0 can use a floating-point, built-in integer, or fixed-point data type that fits in the data type of u. For example, when u uses int32, x0 can use int8 but not double.
The data type of the output signal is the same as the input signal u.
When you specify Delay length and Initial condition on the dialog box, you can use the following data types for those parameters:
| Parameter | Supported Data Types |
|---|---|
| Delay length |
|
| Initial condition |
|
For more information, see Data Types Supported by Simulink in the Simulink documentation.
The Main pane of the Delay block dialog box appears as follows:

Specify whether to enter the delay length directly on the dialog box (fixed delay) or to inherit the delay from an input port (variable delay).
If you set Source to Dialog, enter the delay length in the edit field under Value.
If you set Source to Input port, verify that an upstream signal supplies a delay length for the d input port. You can also specify an Upper limit for the delay length.
The scalar delay length (from the dialog parameter or an input port) must be a real, positive integer.
Specify whether to enter the initial condition directly on the dialog box or to inherit the initial condition from an input port.
If you set Source to Dialog, enter the initial condition in the edit field under Value.
If you set Source to Input port, verify that an upstream signal supplies an initial condition for the x0 input port.
Simulink converts offline the data type of Initial condition to the data type of the input signal u using a round-to-nearest operation and saturation.
Note When State name must resolve to Simulink signal object is selected on the State Attributes pane, the block copies the initial value of the signal object to the Initial condition parameter. However, when the source for Initial condition is Input port, the block ignores the initial value of the signal object. |
Specify the trigger event to use to reset the states to the initial conditions.
| Reset Mode | Behavior |
|---|---|
| None | No reset. |
| Rising | Reset on a rising edge. |
| Falling | Reset on a falling edge. |
| Either | Reset on either a rising or falling edge. |
| Level | Reset in either of these cases:
|
| Level hold | Reset when nonzero at the current time step. |
The reset signal must be scalar.
Specify whether the block performs sample- or frame-based processing. You can select one of the following options:
Elements as channels (sample based) — Treat each element of the input as a separate channel (sample-based processing).
Columns as channels (frame based) — Treat each column of the input as a separate channel (frame-based processing).
Note Frame-based processing requires a DSP System Toolbox license. For more information, see Sample- and Frame-Based Concepts in the DSP System Toolbox documentation. |
Inherited — Inherit the processing mode from the input signal and delay the input accordingly. You can identify whether the input signal is sample or frame based by looking at the signal line. Simulink represents sample-based signals with a single line and frame-based signals with a double line.
Use Input processing to specify whether the block performs sample- or frame-based processing. The block accepts frame-based signals for the input u. All other input signals must be sample based.
| Input Signal u | Input Processing Mode | Block Works? |
|---|---|---|
| Sample based | Sample based | Yes |
| Frame based | No, produces an error | |
| Sample based | Frame based | Yes |
| Frame based | Yes | |
| Sample based | Inherited | Yes |
| Frame based | Yes |
For more information about these two processing modes, see Sample- and Frame-Based Concepts in the DSP System Toolbox documentation.
Select to use a circular buffer for storing the state in simulation and code generation. Otherwise, an array buffer stores the state.
Using a circular buffer can improve execution speed when the delay length is large. For an array buffer, the number of copy operations increases as the delay length goes up. For a circular buffer, the number of copy operations is constant for increasing delay length.
If one of the following conditions is true, an array buffer always stores the state because a circular buffer does not improve execution speed:
For sample-based signals, the delay length is 1.
For frame-based signals, the delay length is no larger than the frame size.
Select to increase the delay length from zero to the lower limit for the Input processing mode:
For sample-based signals, increase the minimum delay length to 1.
For frame-based signals, increase the minimum delay length to the frame length.
Selecting this check box prevents direct feedthrough from the input port, u, to the output port. However, this check box cannot prevent direct feedthrough from the initial condition port, x0, to the output port.
This check box is available when you set Delay length: Source to Input port.
Select to remove code that checks for out-of-range delay length.
| Check Box | Result | When to Use |
|---|---|---|
Selected | Generated code does not include conditional statements to check for out-of-range delay length. | For code efficiency |
Cleared | Generated code includes conditional statements to check for out-of-range delay length. | For safety-critical applications |
This check box is available when you set Delay length: Source to Input port.
Specify whether to produce a warning or error when the input d is less than the lower limit or greater than the Delay length: Upper limit. The lower limit depends on the setting for Prevent direct feedthrough by increasing delay length to lower limit.
If the check box is cleared, the lower limit is zero.
If the check box is selected, the lower limit is 1 for sample-based signals and frame length for frame-based signals.
Options for the diagnostic include:
None — No warning or error appears.
Warning — Display a warning in the MATLAB Command Window and continue the simulation.
Error — Stop the simulation and display an error in the Simulation Diagnostics Viewer.
This parameter is available when you set Delay length: Source to Input port.
Specify the time interval between samples. To inherit the sample time, set this parameter to -1. This block supports discrete sample time, but not continuous sample time.
As described in How to Specify the Sample Time, you can specify a discrete sample time as [Tsampling, Toffset], where Tsampling is the sampling period and Toffset is the initial time offset. If Tstart is the simulation start time and n is the delay length, the Delay block output is as follows.
| Simulation Time Range | Block Output |
|---|---|
(Tstart) to (Tstart + Toffset) | Zero |
(Tstart + Toffset) to (Tstart + Toffset + n * Tsampling) | Initial condition |
After (Tstart + Toffset + n * Tsampling) | Input signal |
If the Delay block inherits or specifies a nonzero value for Toffset, the Delay block outputs zero at Tstart. Otherwise, the Delay block outputs the initial condition at Tstart.
The State Attributes pane of the Delay block dialog box appears as follows:

Use this parameter to assign a unique name to the block state. The default is ' '. When this field is blank, no name is assigned. Consider the following when using this parameter:
A valid identifier starts with an alphabetic or underscore character, followed by alphanumeric or underscore characters.
The state name applies only to the selected block.
This parameter enables State name must resolve to Simulink signal object when you click Apply.
For more information, see States in the Simulink Coder documentation.
Select this check box to require that the state name resolve to a Simulink signal object. This check box is cleared by default.
State name enables this parameter.
Selecting this check box disables Code generation storage class.
Select a package that defines the custom storage class you want to apply. If you have defined any packages of your own, click Refresh. This action adds all user-defined packages on your search path to the package list.
From the list, select a state storage class.
Auto is the storage class to use for states that do not need to interface to external code.
The state is stored in a global variable.
model_private.h declares the state as an extern variable.
model_private.h declares the state as an extern pointer.
State name enables this parameter.
Setting this parameter to ExportedGlobal, ImportedExtern, or ImportedExternPointer enables Code generation storage type qualifier.
Specify a Simulink Coder storage type qualifier. The default is ' '. When this field is blank, no qualifier is assigned.
The Simulink Coder product does not check this string for errors; what you enter appears automatically in the variable declaration.
Setting Code generation storage class to ExportedGlobal, ImportedExtern, or ImportedExternPointer enables this parameter.
The Delay block provides the following support for variable-size signals:
The data input port u accepts variable-size signals. The other input ports do not accept variable-size signals.
The output port has the same signal dimensions as the data input port u for variable-size inputs.
The rules that apply to variable-size signals depend on the input processing mode of the Delay block.
| Input Processing Mode | Rules for Variable-Size Signal Support |
|---|---|
| Elements as channels (sample based) |
|
| Columns as channels (frame based) |
|
| Inherited (where input is a sample-based signal) |
|
| Inherited (where input is a frame-based signal) |
|
The Delay block provides the following support for bus signals:
The data input port u accepts virtual and nonvirtual bus signals. The other input ports do not accept bus signals.
The output port has the same bus type as the data input port u for bus inputs.
Buses work with:
Sample-based and frame-based processing
Fixed and variable delay length
Array and circular buffers
To use a bus signal as the input to a Delay block, you must specify the initial condition on the dialog box. In other words, the initial condition cannot come from the input port x0. Support for virtual and nonvirtual buses depends on the initial condition that you specify and whether the State name parameter is empty or not.
| Initial Condition | State Name | |
|---|---|---|
| Empty | Not Empty | |
| Zero | Virtual and nonvirtual bus support | Nonvirtual bus support only |
| Nonzero scalar | Virtual and nonvirtual bus support | No bus support |
| Nonscalar | No bus support | No bus support |
| Structure | Virtual and nonvirtual bus support | Nonvirtual bus support only |
| Partial structure | Virtual and nonvirtual bus support | Nonvirtual bus support only |
This model shows how the Delay block supports variable-size signals for sample-based processing.

The Switch block controls whether the input signal to the enabled subsystem is a 3-by-3 or 3-by-2 matrix. The Delay block appears inside the enabled subsystem.

The model follows the rules for variable-size signals when the Delay block uses sample-based processing.
| Rule | How the Model Follows the Rule |
|---|---|
The signal dimensions change only during state reset when the block is enabled. | The Enable block sets Propagate sizes of variable-size signals to Only when enabling. |
The initial condition must be scalar. | The Delay block sets Initial condition to 0.0, a scalar value. |
This model shows how the Delay block supports bus signals for frame-based processing.

Each Constant block supplies an input signal to the Bus Creator block, which outputs a two-dimensional bus signal. After the Delay block delays the bus signal by three sample periods, the Bus Selector block separates the bus back into the two original signals.
The model follows the rules for bus signals when the Delay block uses frame-based processing.
| Rule | How the Model Follows the Rule |
|---|---|
For the initial condition, set the value on the dialog box. | The Delay block sets Initial condition to 0, a scalar value. |
For frame-based processing, signal dimensions of the data input port u cannot be larger than two. (This rule applies to all inputs for the port u, not just bus signals.) | The bus input to the Delay block has two dimensions. |
Direct Feedthrough | Yes, when you clear Prevent direct feedthrough by increasing delay length to lower limit |
Sample Time | Specified in the Sample time parameter |
Scalar Expansion | Yes, of the input u when Initial condition is nonscalar and sample-based processing applies |
Dimensionalized | Yes |
Multidimensionalized | Yes |
Zero-Crossing Detection | No |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |