z⁻¹

Unit Delay

Discrete
Run the live example Free · no sign-up · runs in your browser

Delays the input signal by exactly one sample period (TsT_s), representing the fundamental unit delay operator (z−1z^{-1}) in discrete-time signal processing and digital control theory. Serves as the primary unit memory element for constructing Finite Impulse Response (FIR) and Infinite Impulse Response (IIR) digital filters, implementing recurrence relations, resolving algebraic loops in feedback paths, and maintaining state in discrete state machines.

Mathematical Model

In the discrete time domain, the unit delay acts as a single-sample memory buffer:

y[n]={x0,n=0u[n−1],n≥1y[n] = \begin{cases} x_0, & n = 0 \\ u[n-1], & n \ge 1 \end{cases}

In the Z\mathcal{Z}-domain, the transfer function corresponds to the backward shift operator:

H(z)=Y(z)U(z)=z−1H(z) = \frac{Y(z)}{U(z)} = z^{-1}

When the optional bottom reset port r[n]r[n] is driven, the internal register resets synchronously to the initial condition whenever r[n]>0r[n] > 0:

y[n]={x0,r[n]>0u[n−1],r[n]≤0y[n] = \begin{cases} x_0, & r[n] > 0 \\ u[n-1], & r[n] \le 0 \end{cases}

Inputs & Outputs

Direction ID Label Type Status
→ In in Input number Required
→ In reset Reset number Required
← Out out Output number Output

Parameters

Parameters Label Type Default Description
initialCondition Initial Condition number 0

Usage Examples

Example 1: First-Order Discrete Low-Pass Filter (EMA)

An Exponential Moving Average filter computes y[n]=(1−α)⋅u[n]+α⋅y[n−1]y[n] = (1 - \alpha) \cdot u[n] + \alpha \cdot y[n-1] with smoothing coefficient α=0.85\alpha = 0.85. Feeding the output of a Sum block back into a Gain block (K=0.85K = 0.85) through a UnitDelay supplies the prior state y[n−1]y[n-1], placing a discrete pole at z=0.85z = 0.85 and attenuating high-frequency measurement noise.

Example 2: Algebraic Loop Breaking in Closed Feedback

In closed-loop topologies where both controller and plant have direct feedthrough (D≠0D \ne 0), simulators detect an implicit circular dependency at time tt. Inserting a UnitDelay in the feedback sensor path breaks the circular algebraic dependency, allowing the simulation engine to compute the output explicitly using the previous sample's state.

Remarks & Best Practices

  • Sample Time Coupling: Unlike the continuous Delay block which operates over physical seconds, UnitDelay shifts signals by exactly one timestep (1⋅Ts1 \cdot T_s), making its physical delay proportional to the solver's discrete step size.
  • Algebraic Loop Resolution: Placing a UnitDelay on algebraic feedback paths transforms implicit equations into explicit state updates, eliminating algebraic loop warnings and iteration overhead.
  • Synchronous Reset: Driving the optional reset port with a pulse greater than zero immediately resets the stored memory state to initialCondition.
  • Digital Filter Topologies: Forms the canonical building block for Direct Form I, Direct Form II, and lattice filter implementations in discrete-time control.

Related Components

  • Delay: Continuous-time transport delay specified in physical seconds.
  • DiscreteTransferFunction: Higher-order discrete transfer function represented as a polynomial fraction in zz.
  • DiscreteIntegrator: Discrete accumulator implementing Forward Euler, Backward Euler, or Tustin integration.
  • DiscreteDerivative: Computes discrete differences (u[n]−u[n−1])/Ts(u[n] - u[n-1]) / T_s.