t3, imp2 = co.impulse_response(g2, t) t4, stp2 = co.step_response(g2, t) # S = co.step_info(stp1, t, SettlingTimeThreshold=0.01, RiseTimeLimits=(0.1, 0.9)) print("g1 impulse info") signal_info(imp1, t1) print("g1 step info") signal_info(stp1, t2) print("g2 impulse info") signal_info(imp2, t3) print("g2 step info") signal_info(stp2, t4) print("System 1 (m=10) step response info:") step_info(t2, stp1) print("-" * 50) print("System 2 (m=80) step response info:") step_info(t4, stp2) fig, axs = plt.subplots(2, 2, figsize=(7, 7)) plt.subplots_adjust(hspace=0.5, wspace=0.5) axs[0, 0].plot(t1, imp1) axs[0, 0].plot(max_amplitude(imp1, t1)[0], max_amplitude(imp1, t1)[1], "o") axs[0, 1].plot(t3, imp2) axs[0, 1].plot(max_amplitude(imp2, t3)[0], max_amplitude(imp2, t3)[1], "o") axs[1, 0].plot(t2, stp1) axs[1, 0].plot(max_amplitude(stp1, t2)[0], max_amplitude(stp1, t2)[1], "o")
s = co.tf('s') g = (s + 1) / ((s - 1) * (s - 4)) h1 = 1 h2 = 1 / (s - 1) #b) k = 60 gf = co.feedback( k * pd_comp(-4.4) * g, h2, -1 ) # υπολογίζω τους πόλου και τα μηδενικά του κλειστού συστήματος με Κ = 60 και feedback=h2 poles = co.pole(gf) zeros = co.zero(gf) print(f"poles: {poles}") print(f"zeros: {zeros}") plt.figure(1) co.root_locus( pd_comp(-4.4) * g * h2, grid=False) # σχεδιάζω την γραφική παράστασή μου με pd_compensator plot_ts(2) plt.xlim(-15, 5) plt.plot(poles.real, poles.imag, 'rx') t = np.linspace(0, 3, 1000) t1, yout = co.step_response(gf, t) step_info(t1, yout) plt.show()
import control as co import matplotlib.pyplot as plt import numpy as np from functions.my_functions import step_info t = np.linspace(0, 10, 100) s = co.tf('s') g = (s ** 2 + 4 * s + 1) / (s ** 2 - 7 * s + 10) siso = co.sisotool(g) fg = co.feedback(3 * g, sign=-1) t1, impg = co.impulse_response(fg, t) t2, stpg = co.step_response(fg, t) step_info(t2, stpg) fig, ax = plt.subplots(2,1) ax[0].plot(t1, impg) ax[1].plot(t2, stpg) ax[0].set_ylabel("Impulse Response") ax[1].set_ylabel("Step Response") ax[1].set_xlabel("Time") ax[0].grid() ax[1].grid() plt.show()