Hold
DiscreteThe 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 () 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 be the configured sampleTime and () denote the discrete sampling instants.
For the Zero-Order Hold (ZOH) mode:
The frequency response of the ideal ZOH reconstructor in the Laplace domain is:
with an effective phase lag of radians ().
For the First-Order Hold (FOH) mode (linear predictive extrapolation):
On the first sample step (), is initialized to , 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 (). 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 () from a slower digital supervisory monitoring loop running at (). 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 (). 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
sampleTimeis 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 ().
- DiscreteIntegrator: Discrete-time state accumulator with forward/backward Euler and trapezoidal integration.
- Quantizer: Quantizes signal amplitude into discrete resolution steps.
- Clock: Continuous time counter.