In [4]:
import numpy as np
import sympy as sy
import control.matlab as cm
sy.init_printing()

Zero order hold sampling of a first order system

\begin{equation} G(s) = \frac{1}{s-\lambda} \end{equation}

In [9]:
h, lam = sy.symbols('h, lambda', real=True, positive=True)
s, z = sy.symbols('s, z', real=False)

In [10]:
G = 1/(s-lam)
Y = G/s
Yp = sy.apart(Y, s)
Yp


Out[10]:
$$\frac{1}{\lambda \left(- \lambda + s\right)} - \frac{1}{\lambda s}$$

In [11]:
from sympy.integrals.transforms import inverse_laplace_transform
from sympy.abc import t

In [12]:
inverse_laplace_transform(Yp, s, t)


Out[12]:
$$\frac{\theta\left(t\right)}{\lambda} \left(e^{\lambda t} - 1\right)$$

Sampling and taking the z-transform of the step-response

\begin{equation} Y(z) = \frac{1}{\lambda} \left( \frac{z}{z-\mathrm{e}^{\lambda h}} - \frac{z}{z-1} \right). \end{equation}

Dividing by the z-transform of the input signal

\begin{equation} H(z) = \frac{z-1}{z}Y(z) = \frac{1}{\lambda} \left( \frac{ \mathrm{e}^{\lambda h} - 1 }{ z - \mathrm{e}^{\lambda h} } \right) \end{equation}

Verifying for specific value of lambda


In [13]:
lam = -0.5
h = 0.1
G = cm.tf([1], [1, -lam])
Gd = cm.c2d(G, h)
Hd = 1/lam * cm.tf([np.exp(lam*h)-1],[1, np.exp(lam*h)])

In [14]:
print(Gd)
print(Hd)


  0.09754
----------
z - 0.9512

dt = 0.1


  0.09754
----------
s + 0.9512


In [ ]: