⚡

Discrete TF

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

The DiscreteTransferFunction block implements an arbitrary linear discrete-time transfer function H(z)=B(z)A(z)H(z) = \frac{B(z)}{A(z)} in the complex zz-domain using the numerically robust Direct Form II Transposed structure. Polynomial coefficients are specified as space-separated floating-point values arranged in descending powers of zz.

The block also provides an optional reset port to instantly restore internal filter delay states to zero or a designated initial condition during simulation runtime.

Mathematical Model

The pulse transfer function is defined in descending powers of the complex variable z−1z^{-1}:

H(z)=B(z)A(z)=b0+b1z−1+b2z−2+⋯+bmz−ma0+a1z−1+a2z−2+⋯+anz−nH(z) = \frac{B(z)}{A(z)} = \frac{b_0 + b_1 z^{-1} + b_2 z^{-2} + \dots + b_m z^{-m}}{a_0 + a_1 z^{-1} + a_2 z^{-2} + \dots + a_n z^{-n}}

where n≥mn \ge m ensures causality. In the time domain, Direct Form II Transposed maintains nn internal delay states wi[k]w_i[k] (i=1,…,ni = 1, \dots, n):

y[k]=b0u[k]+w1[k−1]a0wi[k]=wi+1[k−1]+biu[k]−aiy[k],i=1,…,n−1wn[k]=bnu[k]−any[k]\begin{aligned} y[k] &= \frac{b_0 u[k] + w_1[k-1]}{a_0} \\ w_i[k] &= w_{i+1}[k-1] + b_i u[k] - a_i y[k], \quad i = 1, \dots, n-1 \\ w_n[k] &= b_n u[k] - a_n y[k] \end{aligned}

Inputs & Outputs

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

Parameters

Parameters Label Type Default Description
numerator Numerator B(z) polynomial 1
denominator Denominator A(z) polynomial 1 -0.5
sampleTime Sample Time number 0.01
initialCondition Initial Condition number 0

Usage Examples

Example 1: First-Order Discrete Lowpass Filter

Implementing a discrete single-pole lowpass filter with pulse transfer function H(z)=0.11−0.9z−1=0.1zz−0.9H(z) = \frac{0.1}{1 - 0.9 z^{-1}} = \frac{0.1 z}{z - 0.9}. Specifying numerator = "0.1 0" and denominator = "1 -0.9" with sampleTime = 0.01 s provides smooth exponential smoothing of noisy sensor signals without numerical drift.

Example 2: Two-Point Moving Average FIR Filter

Constructing a Finite Impulse Response (FIR) filter computing the average of the current and preceding sample: y[k]=0.5u[k]+0.5u[k−1]y[k] = 0.5 u[k] + 0.5 u[k-1], corresponding to H(z)=0.5+0.5z−1=0.5z+0.5zH(z) = 0.5 + 0.5 z^{-1} = \frac{0.5 z + 0.5}{z}. Setting numerator = "0.5 0.5" and denominator = "1 0" yields an unconditionally stable FIR filter with a notch zero at the Nyquist frequency.

Remarks & Best Practices

  • Causality Requirement: The order of the numerator polynomial must not exceed that of the denominator polynomial (deg⁡(B)≤deg⁡(A)\deg(B) \le \deg(A)); strictly non-causal systems cannot be evaluated in real time.
  • Descending Powers Convention: Explicitly include intermediate zero coefficients; for example, z2+1z^2 + 1 must be entered as "1 0 1".
  • Direct Form II Transposed Structure: This realization minimizes sensitivity to coefficient quantization and avoids internal state overflow compared to Direct Form I.
  • BIBO Stability: The transfer function is bounded-input bounded-output (BIBO) stable if and only if all roots of A(z)A(z) lie strictly inside the unit circle of the complex zz-plane (∣zi∣<1|z_i| < 1).
  • Runtime Reset Capability: Applying a positive signal to the optional reset port instantly clears internal delay registers, facilitating rapid controller re-initialization.

Related Components

  • TransferFunction: Continuous-time Laplace transfer function G(s)=B(s)/A(s)G(s) = B(s)/A(s).
  • DiscreteStateSpace: Discrete-time linear system in matrix state-space form.
  • DigitalFilter: Pre-configured IIR/FIR filter block with automatic Butterworth, Chebyshev, and Bessel coefficient calculation.
  • UnitDelay: Fundamental single-sample discrete delay element (z−1z^{-1}).