Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
dynamicslab
GitHub Repository: dynamicslab/databook_python
Path: blob/master/CH08/CH08_SEC08_3_PlantInversion.ipynb
597 views
Kernel: Python 3
import numpy as np import matplotlib.pyplot as plt from matplotlib import rcParams from control.matlab import * import slycot from scipy import signal # Python control toolbox available at https://python-control.readthedocs.io/ plt.rcParams['figure.figsize'] = [8, 8] plt.rcParams.update({'font.size': 18})
s = tf(np.array([1,0]),np.array([0,1])) G = (s+1)/(s-2) Gtrue = (s+0.9)/(s-1.9) K = 1/G L = K*Gtrue fig = plt.figure() gm, pm, wg, wp = margin(L) _,_,_ = bode(L) for ax in fig.axes: xl = ax.get_xlim() yl = ax.get_ylim() ax.plot(wg*np.ones(2),ax.get_ylim(),'k--',linewidth=2) ax.plot(wp*np.ones(2),ax.get_ylim(),'k--',linewidth=2) ax.plot(ax.get_xlim(),np.zeros(2),'k--',linewidth=2) ax.set_xlim(xl) ax.set_ylim(yl) CL = feedback(L,1) CL
s2−1.1s−1.82s2−2s−3.7\frac{s^2 - 1.1 s - 1.8}{2 s^2 - 2 s - 3.7}
Image in a Jupyter notebook