⏸

Hold

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

The Hold block implements sample-and-hold operations for discrete-time signal processing and hybrid continuous-discrete systems. It periodically samples an incoming continuous or discrete signal at uniform sampling intervals (TsT_s) and reconstructs an output waveform across the inter-sample period. The block supports two standard reconstruction algorithms: Zero-Order Hold (ZOH), which holds the most recent sample constant as a piecewise flat staircase, and First-Order Hold (FOH), which performs linear extrapolation based on the slope between the two most recent samples.

Mathematical Model

Let TsT_s be the configured sampleTime and tk=k⋅Tst_k = k \cdot T_s (k∈Z≥0k \in \mathbb{Z}_{\ge 0}) denote the discrete sampling instants.

For the Zero-Order Hold (ZOH) mode:

y(t)=u(tk)for tk≤t<tk+1y(t) = u(t_k) \quad \text{for } t_k \le t < t_{k+1}

The frequency response of the ideal ZOH reconstructor in the Laplace domain is:

GZOH(s)=1−e−sTssG_{\text{ZOH}}(s) = \frac{1 - e^{-s T_s}}{s}

with an effective phase lag of θlag=−ωTs2\theta_{\text{lag}} = -\frac{\omega T_s}{2} radians (−ωTs2⋅180∘π-\frac{\omega T_s}{2} \cdot \frac{180^\circ}{\pi}).

For the First-Order Hold (FOH) mode (linear predictive extrapolation):

y(t)=u(tk)+u(tk)−u(tk−1)Ts(t−tk)for tk≤t<tk+1y(t) = u(t_k) + \frac{u(t_k) - u(t_{k-1})}{T_s} (t - t_k) \quad \text{for } t_k \le t < t_{k+1}

On the first sample step (k=0k = 0), u(t−1)u(t_{-1}) is initialized to u(t0)u(t_0), resulting in flat zero-order hold behavior for the initial interval.

Inputs & Outputs

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

Parameters

Parameters Label Type Default Description
mode Hold Mode select zoh
sampleTime Sample Time number 0.01

Usage Examples

Example 1: Digital-to-Analog Converter (DAC) Zero-Order Hold Modeling

Simulating the output stage of a discrete microcontroller digital-to-analog converter (DAC) operating at 100 Hz100\text{ Hz} (Ts=0.01 sT_s = 0.01\text{ s}). Routing the discrete controller command into a Hold block with mode = "zoh" and sampleTime = 0.01 s reproduces the exact zero-order hold staircase waveform and phase lag encountered by physical power electronics actuators.

Example 2: Multirate Subsystem Sampling Rate Transition

Decoupling a fast continuous plant solver running at Δt=0.001 s\Delta t = 0.001\text{ s} (1 kHz1\text{ kHz}) from a slower digital supervisory monitoring loop running at Ts=0.1 sT_s = 0.1\text{ s} (10 Hz10\text{ Hz}). Inserting a Hold block with sampleTime = 0.1 ensures that the supervisory loop only processes downsampled data at its native clock rate without aliasing solver substeps.

Remarks & Best Practices

  • Phase Lag in Control Loops: Zero-Order Hold inherently introduces an effective pure time delay equal to half the sample period (τd≈Ts/2\tau_d \approx T_s / 2). In feedback control design, this phase lag must be budgeted into the loop phase margin to prevent instability.
  • ZOH vs. FOH Numerical Stability: ZOH is bounded and unconditionally stable; FOH linearly extrapolates and can project overshoot or ringing when encountering sharp signal transients.
  • Sample Time Alignment: If sampleTime is set smaller than the simulation solver base step size, the block clamps sampling to the solver step size to ensure deterministic execution.
  • Multirate Bridging: Serves as the canonical interface block between continuous-time dynamic subsystems and discrete-time digital controllers.

Related Components

  • UnitDelay: Delays a discrete signal by exactly one sample period (z−1z^{-1}).
  • DiscreteIntegrator: Discrete-time state accumulator with forward/backward Euler and trapezoidal integration.
  • Quantizer: Quantizes signal amplitude into discrete resolution steps.
  • Clock: Continuous time counter.