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.001151z² + 0.003973z + 0.0008525z³ − 2.489z² + 2.038z − 0.5488
- Poles of G(z)
- 0.67030.81871
- Zeros of G(z)
- −3.222−0.2299
- DC gain G(1)
- ∞
- largest |z|
- 1
- Stability
- G(z) is marginally stable: poles on the unit circle.
y[k] = 2.489·y[k−1] − 2.038·y[k−2] + 0.5488·y[k−3] + 0.001151·u[k−1] + 0.003973·u[k−2] + 0.0008525·u[k−3]
- 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)
The continuous system is not stable, so the plot shows the growing response over a short horizon.
All three methods at this T
| Method | G(z) | Poles | Gap from y(kT) | Stable |
|---|---|---|---|---|
| Zero-order hold | (0.001151z² + 0.003973z + 0.0008525) / (z³ − 2.489z² + 2.038z − 0.5488) | 0.6703, 0.8187, 1 | 0 (exact for a held step) | marginal |
| Tustin (bilinear) | (0.0007576z³ + 0.002273z² + 0.002273z + 0.0007576) / (z³ − 2.485z² + 2.03z − 0.5455) | 0.6667, 0.8182, 1 | 0.05 | marginal |
| Matched pole–zero | (0.001494z² + 0.002988z + 0.001494) / (z³ − 2.489z² + 2.038z − 0.5488) | 0.6703, 0.8187, 1 | 0.00499 | marginal |
Same result in code
% G(s) = (1) / (s^3 + 3s^2 + 2s)
G = tf([1], [1 3 2 0]);
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([1], [1, 3, 2, 0])
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.