Documentation

Unit Delay

Delay signal one sample period

Library

Discrete

Description

The Unit Delay block holds and delays its input by the sample period you specify. This block is equivalent to the z-1 discrete-time operator. The block accepts one input and generates one output. Each signal can be scalar or vector. If the input is a vector, the block holds and delays all elements of the vector by the same sample period.

You specify the block output for the first sampling period with the Initial conditions parameter. Careful selection of this parameter can minimize unwanted output behavior. You specify the time between samples with the Sample time parameter. A setting of -1 means the block inherits the Sample time.

    Note:   The Unit Delay block errors out if you use it to create a transition between blocks operating at different sample rates. Use the Rate Transition block instead.

Comparison with Similar Blocks

Blocks with Similar Functionality

The Unit Delay, Memory, and Zero-Order Hold blocks provide similar functionality but have different capabilities. Also, the purpose of each block is different. The sections that follow highlight some of these differences.

Recommended Usage for Each Block

BlockPurpose of the BlockReference Examples
Unit DelayImplement a delay using a discrete sample time that you specify. The block accepts and outputs signals with a discrete sample time.
MemoryImplement a delay by one major integration time step. Ideally, the block accepts continuous (or fixed in minor time step) signals and outputs a signal that is fixed in minor time step.
Zero-Order HoldConvert an input signal with a continuous sample time to an output signal with a discrete sample time.

Overview of Block Capabilities

CapabilityBlock
Unit DelayMemoryZero-Order Hold
Specification of initial conditionYesYesNo, because the block output at time t = 0 must match the input value.
Specification of sample timeYesNo, because the block can only inherit sample time (from the driving block or the solver used for the entire model).Yes
Support for frame-based signalsYesNo Yes
Support for state loggingYesNoNo

Data Type Support

The Unit Delay block accepts real or complex signals of any data type that Simulink® supports, including fixed-point and enumerated data types. If the data type of the input signal is user-defined, the initial condition must be zero.

For more information, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

During simulation, the block uses the following values:

  • The initial value of the signal object to which the state name is resolved

  • Min and Max values of the signal object

For more information, see Discrete Block State Naming in Generated Code in the Simulink Coder™ documentation.

Initial conditions

Specify the output of the simulation for the first sampling period, during which the output of the Unit Delay block is otherwise undefined.

Settings

Default: 0

The Initial conditions parameter is converted from a double to the input data type offline using round-to-nearest and saturation.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Input processing

Specify whether the Unit Delay block performs sample- or frame-based processing.

Settings

Default: Elements as channels (sample based)

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).

Inherited

Sets the block to 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.

    Note:   When you choose the Inherited option for the Input processing parameter, and the input signal is frame-based, Simulink® will generate a warning or error in future releases.

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 uInput Processing ModeBlock Works?
Sample basedSample basedYes
Frame basedNo, produces an error
Sample basedFrame basedYes
Frame basedYes
Sample basedInheritedYes
Frame basedYes

For more information about these two processing modes, see Sample- and Frame-Based Concepts in the DSP System Toolbox™ documentation.

Dependency

Frame-based processing requires a DSP System Toolbox license.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Sample time (-1 for inherited)

Enter the discrete interval between sample time hits or specify -1 to inherit the sample time.

Settings

Default: -1

By default, the block inherits its sample time based upon the context of the block within the model. To set a different sample time, enter a valid sample time based upon the table in Types of Sample Time.

See also Specify Sample Time in the online documentation for more information.

Command-Line Information

See Block-Specific Parameters for the command-line information.

State name

Use this parameter to assign a unique name to each state.

Settings

Default: ' '

  • If left blank, no name is assigned.

Tips

  • 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.

Dependency

This parameter enables State name must resolve to Simulink signal object when you click the Apply button.

For more information, see Discrete Block State Naming in Generated Code in the Simulink Coder documentation.

Command-Line Information

Parameter: StateIdentifier
Type: string
Value: ' '
Default: ' '

State name must resolve to Simulink signal object

Require that state name resolve to Simulink signal object.

Settings

Default: Off

On

Require that state name resolve to Simulink signal object.

Off

Do not require that state name resolve to Simulink signal object.

Dependencies

State name enables this parameter.

Selecting this check box disables Code generation storage class.

Command-Line Information

Parameter: StateMustResolveToSignalObject
Type: string
Value: 'off' | 'on'
Default: 'off'

Signal object class

Choose a custom storage class package by selecting a signal object class that the target package defines. For example, to apply custom storage classes from the built-in package mpt, select mpt.Signal. Unless you use an ERT-based code generation target with Embedded Coder® software, custom storage classes do not affect the generated code.

Settings

Simulink.Signal

Use custom storage classes from the built-in package Simulink.

Package.Class

Use custom storage classes from the package that defines the class that you select.

If the class that you want does not appear in the list, select Customize class lists. For instructions, see Apply Custom Storage Classes Directly to Signal Lines and Block States.

Code generation storage class

Select state storage class for code generation.

Settings

Default: Auto

Auto

Auto is the appropriate storage class for states that you do not need to interface to external code.

StorageClass

Applies the storage class or custom storage class that you select from the list. For information about storage classes, see Control Signals and States in Code by Applying Storage Classes. For information about custom storage classes, see Control Data Representation by Applying Custom Storage Classes.

Use Signal object class to select custom storage classes from a package other than Simulink.

Dependencies

State name enables this parameter.

TypeQualifier

    Note:   TypeQualifier will be removed in a future release. To apply storage type qualifiers to data, use custom storage classes and memory sections. Unless you use an ERT-based code generation target with Embedded Coder software, custom storage classes and memory sections do not affect the generated code.

Specify a storage type qualifier such as const or volatile.

Settings

  • Default: ' ' (empty string)

  • const

  • volatile

Dependency

Setting Code generation storage class to ExportedGlobal, ImportedExtern, ImportedExternPointer, or SimulinkGlobal enables this parameter. This parameter is hidden unless you previously set its value.

Command-Line Information

Parameter Name: RTWStateStorageTypeQualifier
Value Type: string
Default: ' ' (empty string)

Bus Support

The Unit Delay block is a bus-capable block. The input can be a virtual or nonvirtual bus signal subject to the following restrictions:

  • Initial conditions must be zero, a nonzero scalar, or a finite numeric structure.

  • If Initial conditions is zero or a structure, and you specify a State name, the input cannot be a virtual bus.

  • If Initial conditions is a nonzero scalar, no State name can be specified.

For information about specifying an initial condition structure, see Specify Initial Conditions for Bus Signals.

All signals in a nonvirtual bus input to a Unit Delay block must have the same sample time, even if the elements of the associated bus object specify inherited sample times. You can use a Rate Transition block to change the sample time of an individual signal, or of all signals in a bus. See Composite Signals and Bus-Capable Blocks for more information.

You can use an array of buses as an input signal to a Unit Delay block. You can specify the Initial conditions parameter with:

  • The value 0. In this case, all of the individual signals in the array of buses use the initial value 0.

  • An array of structures that specifies an initial condition for each of the individual signals in the array of buses.

  • A single scalar structure that specifies an initial condition for each of the elements that the bus type defines. Use this technique to specify the same initial conditions for each of the buses in the array.

For details about defining and using an array of buses, see Combine Buses into an Array of Buses.

Examples

For an example of how to use the Unit Delay block, see the sldemo_enginewc model. The Unit Delay block appears in the Compression subsystem.

Characteristics

Data Types

Double | Single | Boolean | Base Integer | Fixed-Point | Enumerated | Bus

Sample Time

Specified in the Sample time parameter

Direct Feedthrough

No

Multidimensional Signals

Yes

Variable-Size Signals

Yes

Zero-Crossing Detection

No

Code Generation

Yes

Introduced before R2006a

Was this topic helpful?