!pip install control
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/ Requirement already satisfied: control in /usr/local/lib/python3.10/dist-packages (0.9.3.post2) Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from control) (3.7.1) Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from control) (1.22.4) Requirement already satisfied: scipy>=1.3 in /usr/local/lib/python3.10/dist-packages (from control) (1.10.1) Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->control) (4.39.3) Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib->control) (2.8.2) Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib->control) (0.11.0) Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->control) (8.4.0) Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->control) (1.0.7) Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->control) (23.1) Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->control) (1.4.4) Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->control) (3.0.9) Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib->control) (1.16.0)
import numpy as np
import matplotlib.pyplot as plt
from control.matlab import *
num = np.array([1])
den = np.array([1, 1, 0])
G = tf(num, den)
ar = 2
rlocus(G)
fig = plt.gcf().set_size_inches(8, 8)
plt.xlim([-ar, ar]), plt.ylim([-ar, ar])
plt.grid()
plt.show()
num = np.array([1,2])
den = np.array([1,4,0,0])
G = tf(num, den)
ar = 10
rlocus(G)
fig = plt.gcf().set_size_inches(8, 8)
plt.xlim([-ar, ar]), plt.ylim([-ar, ar])
plt.grid()
plt.show()
zeros = [9j, -9j, -5]
poles = [0, 0, 10j, -10j]
G = zpk(zeros, poles, 1)
ar = 20
rlocus(G)
fig = plt.gcf().set_size_inches(8, 8)
plt.xlim([-ar, ar]), plt.ylim([-ar, ar])
plt.grid()
plt.show()
zeros = [1]
poles = [2, 3, -10]
G = zpk(zeros, poles, 1)
ar = 20
rlocus(G)
fig = plt.gcf().set_size_inches(8, 8)
plt.xlim([-ar, ar]), plt.ylim([-ar, ar])
plt.grid()
plt.show()
zeros = [1]
poles = [2, 3, -10, -20]
G = zpk(zeros, poles, 1)
kvec_ = [0,10,200,1050]
rlist, klist = rlocus(G, kvec_,plot=False);
print(rlist)
ar = 20
rlocus(G)
fig = plt.gcf().set_size_inches(8, 8)
plt.xlim([-ar, ar]), plt.ylim([-ar, ar])
plt.plot(rlist[2].real, rlist[2].imag, "rx", label=f"K={kvec_[2]}")
plt.plot(rlist[3].real, rlist[3].imag, "gx", label=f"K={kvec_[3]}")
plt.legend()
plt.grid()
plt.show()
[[-20. +0.j -10. +0.j 2. +0.j 3. +0.j ] [-20.0412611 +0.j -9.92963656+0.j 2.04089322+0.j 2.93000444+0.j ] [-20.74901846+0.j -8.62980666+0.j 2.18941256-0.88948992j 2.18941256+0.88948992j] [-22.98674803+0.j -0.63492445+2.89391526j -0.74340308+0.j -0.63492445-2.89391526j]]
zr = [-3, 11j, -11j]
pl = [0, 0, 10j, -10j,-11,-11]
G = zpk(zr, pl, 1)
ar = 20
rlocus(G)
fig = plt.gcf().set_size_inches(8, 8)
plt.xlim([-ar, ar]), plt.ylim([-ar, ar])
plt.grid()
plt.show()