Unit Delay

Delay signal one sample period

  • Library:
  • Simulink / Discrete

    HDL Coder / Discrete

Description

The Unit Delay block holds and delays its input by the sample period you specify. When placed in an iterator subsystem, it holds and delays its input by one iteration. 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

The Memory, Unit Delay, and Zero-Order Hold blocks provide similar functionality but have different capabilities. Also, the purpose of each block is different.

This table shows 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.

Each block has the following capabilities.

CapabilityMemoryUnit DelayZero-Order Hold
Specification of initial conditionYesYesNo, because the block output at time t = 0 must match the input value.
Specification of sample timeNo, because the block can only inherit sample time from the driving block or the solver used for the entire model.YesYes
Support for frame-based signalsNo YesYes
Support for state loggingNoYesNo

Ports

Input

expand all

Input signal that the block delays by one sample period.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | enumerated | bus

Output

expand all

Output signal that is the input delayed by one sample period.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | enumerated | bus

Parameters

expand all

Main

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

Programmatic Use

Block Parameter: InitialCondition
Type: character vector
Value: scalar | vector
Default: '0'

Specify whether the block performs sample- or frame-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 (DSP System Toolbox).

  • Elements as channels (sample based) — Treat each element of the input as a separate channel (sample-based processing).

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

For more information about these two processing modes, see Sample- and Frame-Based Concepts (DSP System Toolbox).

Programmatic Use

Block Parameter: InputProcessing
Type: character vector
Values: 'Columns as channels (frame based)' | 'Elements as channels (sample based)'
Default: 'Elements as channels (sample based)'

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

See also Specify Sample Time.

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Value: real scalar
Default: '-1'

State Attributes

Use this parameter to assign a unique name to the block state. The default is ' '. When this field is blank, no name is assigned. When using this parameter, remember these considerations:

  • 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 Apply Storage Classes to Individual Signal, State, and Parameter Data Elements (Simulink Coder).

Programmatic Use

Block Parameter: StateName
Type: character vector
Values: unique name
Default: ''

Specify if requiring that state name resolve to Simulink signal objects or not. If selected, the software generates an error at run time if you specify a state name that does not match the name of a Simulink signal object.

Dependency

Enabled when you give the parameter State name a value and set the model configuration parameter Signal resolution to a value other than None.

Selecting this check box disables Code generation storage class.

Programmatic Use

Block Parameter: StateMustResolveToSignalObject
Type: character vector
Values: 'off' | 'on'
Default: 'off'

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®, custom storage classes do not affect the generated code.

If the class that you want does not appear in the list, select Customize class lists. For instructions, see Target Class Does Not Appear in List of Signal Object Classes (Embedded Coder).

For information about storage classes, see Apply Storage Classes to Individual Signal, State, and Parameter Data Elements (Simulink Coder). For information about custom storage classes, see Apply Custom Storage Classes to Individual Signal, State, and Parameter Data Elements (Embedded Coder).

Programmatic Use

Block Parameter: StateSignalObject
Type: character vector
Values: 'Simulink.Signal' | '<StorageClass.PackageName>'
Default: 'Simulink.Signal'

Select state storage class for code generation. If you do not need to interface to external code, select Auto.

For more information, see Apply Storage Classes to Individual Signal, State, and Parameter Data Elements (Simulink Coder) and Apply Custom Storage Classes to Individual Signal, State, and Parameter Data Elements (Embedded Coder).

Programmatic Use

Block Parameter: StateStorageClass
Type: character vector
Values: 'Auto' | 'Model default' | 'ExportedGlobal'' | 'ImportedExtern' | 'ImportedExternPointer' | 'Custom'
Default: 'Auto'

Block Characteristics

Data Types

Boolean | bus | double | enumerated | fixed point | integer | single

Direct Feedthrough

yes

Multidimensional Signals

yes

Variable-Size Signals

yes

Zero-Crossing Detection

no

Extended Capabilities

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Fixed-Point Conversion
Convert floating-point algorithms to fixed point using Fixed-Point Designer™.

Introduced before R2006a