import numpy as np import matplotlib.pyplot as plt from scipy.signal import TransferFunction, step def step_rc(R, C, t_end, step_amplitude): # Define the transfer function H(s) = 1 / (RCs + 1) num = [1] den = [R * C, 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) # Scale the response by the step amplitude response *= step_amplitude # Plot the step response plt.plot(t, response) plt.title('Step Response of RC Circuit') plt.xlabel('Time (s)') plt.ylabel('Response (V)') plt.grid(True) plt.show() return t, response # Example usage R = 1000 # Ohms C = 1e-6 # Farads t_end = 0.01 # seconds step_amplitude = 5 # Volts t, response = step_rc(R, C, t_end, step_amplitude)