Discretization calculator: G(s) to G(z)
Enter G(s) and a sampling period T, pick zero-order hold, Tustin or matched pole–zero, and get G(z), its poles and zeros on the z-plane, the difference equation to put in code, and the discrete step response next to the continuous one.
- Discrete system (Zero-order hold)
- G(z) =0.06941z + 0.06071z² − 1.54z + 0.6703
- Poles of G(z)
- 0.7701 ± 0.278j
- Zeros of G(z)
- −0.8747
- DC gain G(1)
- 1
- largest |z|
- 0.8187
- Stability
- G(z) is stable: every pole is inside the unit circle.
y[k] = 1.54·y[k−1] − 0.6703·y[k−2] + 0.06941·u[k−1] + 0.06071·u[k−2]
- Sampling frequency ωs
- 31.42 rad/s
- Nyquist frequency π/T
- 15.71 rad/s
- Fastest pole |p|·T
- 0.4
- Largest gap from y(kT)
- 0 (exact for a held step)
All three methods at this T
| Method | G(z) | Poles | Gap from y(kT) | Stable |
|---|---|---|---|---|
| Zero-order hold | (0.06941z + 0.06071) / (z² − 1.54z + 0.6703) | 0.7701 ± 0.278j | 0 (exact for a held step) | yes |
| Tustin (bilinear) | (0.03226z² + 0.06452z + 0.03226) / (z² − 1.548z + 0.6774) | 0.7742 ± 0.2794j | 0.0987 | yes |
| Matched pole–zero | (0.06506z + 0.06506) / (z² − 1.54z + 0.6703) | 0.7701 ± 0.278j | 0.0074 | yes |
Same result in code
% G(s) = (4) / (s^2 + 2s + 4)
G = tf([4], [1 2 4]);
Ts = 0.2;
Gd = c2d(G, Ts, 'zoh')
p = pole(Gd), abs(p) % stable when every |p| < 1
z = zero(Gd)
[b, a] = tfdata(Gd, 'v') % y[k] = -a(2)y[k-1] - ... + b(1)u[k] + b(2)u[k-1] + ...
step(G, Gd); grid on % continuous against discreteimport numpy as np
import control as ct
G = ct.tf([4], [1, 2, 4])
Ts = 0.2
Gd = ct.sample_system(G, Ts, method='zoh')
print(Gd)
p = ct.poles(Gd); print(p, np.abs(p)) # stable when every |p| < 1
print(ct.zeros(Gd))
resp = ct.step_response(Gd)MATLAB uses the Control System Toolbox; Python uses python-control 0.10 or later (pip install control).
What this calculator computes
A pulse transfer function G(z) = Y(z)/U(z) that relates the samples y[k] = y(kT) to the computer's commands u[k], and the same relation written as a difference equation.
For the z-transform lecture's plant 1/(s + 1) at T = 0.2 s, the zero-order hold gives G(z) = 0.1813/(z − 0.8187): the pole is e^(−0.2) and the DC gain stays 1. Tustin turns the lecture's filter 10/(s + 10) at T = 0.05 s into 0.2(z + 1)/(z − 0.6).
How to read the result
- Poles inside the unit circle mean a stable G(z); a pole on the circle is marginal. The zero-order hold and matched methods put each continuous pole p at z = e^(pT); Tustin puts it at (1 + pT/2)/(1 − pT/2).
- The difference equation is G(z) read with z⁻¹ as a one-sample delay: y[k] comes from earlier outputs and the current and earlier inputs. When G(z) is strictly proper only earlier inputs appear, so a controller has one sample to compute.
- The step plot shows the continuous response as a curve and y[k] as dots. With the zero-order hold the dots sit exactly on the curve, because the hold makes the input exactly a step; the largest gap at the sampling instants is listed for every method.
Method and conventions
- Zero-order hold: G(s) is realized in state space, and one matrix exponential of [[A, B], [0, 0]]·T gives Φ = e^(AT) and Γ = ∫₀ᵀ e^(Aτ)dτ·B. Then G(z) = C(zI − Φ)⁻¹Γ + D, the way MATLAB c2d computes it.
- Tustin substitutes s = (2/T)(z − 1)/(z + 1). With a prewarp frequency ω the factor 2/T becomes ω/tan(ωT/2), so G(z) on the unit circle equals G(jω) exactly at that frequency.
- Matched pole–zero maps poles and finite zeros by z = e^(sT), sends all but one zero at infinity to z = −1 so that one sample of delay remains, and matches the DC gain (with integrators, the low-frequency gain). This is MATLAB's convention; textbooks often move the last zero to −1 as well, and python-control moves none, so its code adds them.
One input and one output, proper G(s) up to degree 12, and T from 1 µs to 1000 s. When T is short compared with the slowest pole, the poles crowd near z = 1 and the polynomial coefficients lose digits; MATLAB has the same limit. Time delay is not modeled.