import numpy as np import matplotlib.pyplot as plt from scipy.signal import TransferFunction, step def step_response(T, t_end): # Define the transfer function H(s) = (-Ts + 1) / (s^3 + 3s^2 + 2s + 1) num = [-T, 1] den = [1, 3, 2, 1] system = TransferFunction(num, den) # Generate time points t = np.linspace(0, t_end, 1000) # Calculate the step response t, response = step(system, T=t) # Plot the step response plt.plot(t, response) plt.title('Step Response of the System') plt.xlabel('Time (s)') plt.ylabel('Response') plt.grid(True) plt.show() return t, response # Example usage T = 1 # Time constant t_end = 10 # seconds t, response = step_response(T, t_end)