S-domain And Z-domain Analysis Python Analysis

5 min read

Signal processing and control systems engineering rely heavily on mathematical transforms to move problems from the time domain—where differential and difference equations reign—into algebraic domains where solutions become tractable. Practically speaking, the s-domain (Laplace transform) governs continuous-time systems, while the z-domain (Z-transform) rules discrete-time systems. Performing s-domain and z-domain analysis Python analysis bridges the gap between theoretical classroom derivations and practical engineering implementation, allowing engineers to design filters, controllers, and communication systems with high precision.

Understanding the Theoretical Foundations

Before diving into code, it is crucial to distinguish the mathematical landscapes we are navigating. Also, the Laplace transform converts a continuous-time function $f(t)$ into a complex frequency domain representation $F(s)$, where $s = \sigma + j\omega$. This transformation turns linear differential equations into algebraic polynomials, making stability analysis (via pole locations) and transfer function manipulation straightforward The details matter here. Turns out it matters..

Conversely, the Z-transform performs a similar service for discrete-time sequences $x[n]$, mapping them to $X(z)$ where $z = re^{j\omega}$. The relationship between the two is often visualized through the mapping $z = e^{sT_s}$, where $T_s$ is the sampling period. Plus, it is the discrete counterpart to the Laplace transform. This mapping warps the left-half s-plane (stable region) into the interior of the unit circle in the z-plane Simple, but easy to overlook..

When conducting s-domain and z-domain analysis Python analysis, libraries like scipy.And signal, control, and sympy become indispensable. They handle the heavy lifting of polynomial algebra, partial fraction expansion, and inverse transforms, allowing the engineer to focus on system architecture rather than algebraic manipulation.

Setting Up the Python Environment

A reliable environment is the first step. The scientific Python stack centers around NumPy and SciPy. For control-specific tasks—like root locus plots, Bode diagrams, and state-space conversions—the control library (often called python-control) is the industry standard wrapper mimicking MATLAB syntax. For symbolic mathematics, such as deriving transfer functions symbolically or performing inverse Laplace transforms analytically, sympy is unmatched.

Short version: it depends. Long version — keep reading.

# Core numerical libraries
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal as sig

# Control systems library (pip install control)
import control as ctrl

# Symbolic math library (pip install sympy)
import sympy as sp

# For pretty printing in notebooks
sp.init_printing(use_unicode=True)

Ensure these are installed via pip install numpy scipy matplotlib control sympy. With the environment ready, we can explore specific analysis workflows.

Continuous-Time Analysis in the S-Domain

The control library treats transfer functions as first-class objects. Defining a system in the s-domain involves specifying numerator and denominator polynomial coefficients in descending powers of $s$ Still holds up..

Consider a standard second-order system: $ H(s) = \frac{\omega_n^2}{s^2 + 2\zeta\omega_n s + \omega_n^2} $

Defining and Inspecting the System

# System parameters
wn = 10.0      # Natural frequency (rad/s)
zeta = 0.3     # Damping ratio

# Numerator and Denominator coefficients
num = [wn**2]
den = [1, 2*zeta*wn, wn**2]

# Create Transfer Function object
sys_s = ctrl.tf(num, den)
print(sys_s)

Output:

      100
-------------------
s^2 + 6 s + 100

Pole-Zero Map and Stability

Stability in the s-domain requires all poles to reside in the Left Half Plane (LHP). The pole() and zero() functions extract these roots instantly Took long enough..

poles = ctrl.pole(sys_s)
zeros = ctrl.zero(sys_s)

print("Poles:", poles)
print("Zeros:", zeros)

# Plot Pole-Zero Map
ctrl.pzmap(sys_s, plot=True, title="S-Domain Pole-Zero Map")
plt.grid()
plt.show()

For $\zeta = 0.In practice, 3$, the poles are complex conjugates with negative real parts ($-3 \pm j9. 54$), confirming an underdamped, stable system That's the part that actually makes a difference..

Time and Frequency Response

The true power of s-domain and z-domain analysis Python analysis lies in visualizing system behavior.

# 1. Step Response
time, response = ctrl.step_response(sys_s)
plt.figure()
plt.plot(time, response)
plt.title("Step Response (S-Domain)")
plt.xlabel("Time (s)")
plt.ylabel("Amplitude")
plt.grid()
plt.show()

# 2. Bode Plot (Frequency Response)
plt.figure()
ctrl.bode(sys_s, dB=True, Hz=False, deg=True)
plt.suptitle("Bode Plot (S-Domain)")
plt.show()

The step response reveals overshoot and settling time directly linked to pole locations. The Bode plot provides gain and phase margins, critical for control loop design The details matter here..

Symbolic Inverse Laplace with SymPy

Sometimes, an analytical time-domain expression $h(t)$ is required for documentation or further mathematical manipulation. sympy excels here Worth keeping that in mind..

s, t = sp.symbols('s t', positive=True)
wn_sym, zeta_sym = sp.symbols('wn zeta', positive=True)

H_s = wn_sym**2 / (s**2 + 2*zeta_sym*wn_sym*s + wn_sym**2)
h_t = sp.inverse_laplace_transform(H_s, s, t)
sp.simplify(h_t)

This yields the symbolic expression: $ h(t) = \frac{\omega_n e^{-\zeta \omega_n t} \sin\left(\omega_n t \sqrt{1 - \zeta^2}\right)}{\sqrt{1 - \zeta^2}} $ This capability distinguishes deep s-domain and z-domain analysis Python analysis from mere numerical simulation.

Discrete-Time Analysis in the Z-Domain

Digital controllers and digital signal processing (DSP) filters operate in the z-domain. The workflow mirrors the continuous case but with critical differences in interpretation.

Creating Discrete Transfer Functions

In python-control, a discrete transfer function is created by passing a sampling time dt (or Ts) to the tf constructor.

Ts = 0.01  # Sampling time 10ms -> 100 Hz sampling rate

# Example: Discrete integrator (Forward Euler) H(z) = Ts / (z - 1)
# Note: control library expects polynomials in z^-1 (descending powers of z)
# or standard z polynomials. We use standard z polynomials here.
num_d = [Ts]
den_d = [1, -1] # z - 1

sys_z = ctrl.tf(num_d, den_d, dt=Ts)
print(sys_z)

Output:

  0.01
-------
z - 1
dt = 0.01

Stability in the Z-Plane

Stability criteria shift: poles must lie inside the unit circle ($|z| < 1$).

poles_z = ctrl.pole(sys_z)
print("Z-Domain Poles:", poles_z)
print("Magnitudes:", np.abs(poles_z))

# Pole-Zero Map for Discrete System
ctrl.pzmap(sys_z, plot=True, title="Z-Domain Pole-Zero Map (Unit Circle)")
plt.grid()
plt.show()

The pole is at $z=1$ (magnitude 1.0). This indicates marginal stability (an accumulator), a classic result for a pure integrator.

Frequency Response: freqz vs bode

For discrete systems, the frequency response is evaluated on the unit circle $z = e^{j\omega T_s}$. signal.While ctrl.bode works, scipy.freqz is the DSP standard for digital filter analysis, returning normalized frequency (radians/sample) Worth knowing..

# Using scipy.signal for standard DSP analysis
w, h =
Hot New Reads

Just Went Live

These Connect Well

Keep Exploring

Thank you for reading about S-domain And Z-domain Analysis Python Analysis. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home