import numpy as np import control import matplotlib.pyplot as plt # %% Generating a z-transfer function of a time delay: Ts = 0.1 Td = 5 nd = int(Td/Ts) denom_tf = np.append([1], np.zeros(nd)) H_delay = control.tf([1], denom_tf, Ts) # %% Displaying the z-transfer function: print('H_delay(z) =', H_delay) # %% Sim of step response of time delay transfer function: t = np.arange(0, 10+Ts, Ts) (t, y) = control.step_response(H_delay, t) y = y[0,:] # Turning 2D array into 1D array for plotting plt.plot(t, y) plt.xlabel('t [s]') plt.grid() # %% Generating pdf file of the plotting figure: plt.savefig('step_response_hz_time_delay.pdf')