Skip to content

Commit bfd9279

Browse files
author
Victor
committed
Added discrete grid to pzmap function.
1 parent 601b581 commit bfd9279

1 file changed

Lines changed: 37 additions & 2 deletions

File tree

control/pzmap.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,42 @@
4040
#
4141
# $Id:pzmap.py 819 2009-05-29 21:28:07Z murray $
4242

43-
from numpy import real, imag
44-
from .lti import LTI
43+
from numpy import real, imag, linspace, pi, exp, cos, sin, sqrt
44+
from .lti import LTI, isdtime, isctime
4545

4646
__all__ = ['pzmap']
4747

48+
def zgrid(plt):
49+
for zeta in linspace(0, 0.9,10):
50+
factor = zeta/sqrt(1-zeta**2)
51+
x = linspace(0, sqrt(1-zeta**2),200)
52+
ang = pi*x
53+
mag = exp(-pi*factor*x)
54+
xret = mag*cos(ang)
55+
yret = mag*sin(ang)
56+
plt.plot(xret,yret, 'k:', lw=1)
57+
xret = mag*cos(-ang)
58+
yret = mag*sin(-ang)
59+
plt.plot(xret,yret,'k:', lw=1)
60+
an_i = int(len(xret)/2.5)
61+
an_x = xret[an_i]
62+
an_y = yret[an_i]
63+
plt.annotate(str(zeta), xy=(an_x, an_y), xytext=(an_x, an_y), size=7)
64+
65+
for a in linspace(0,1,10):
66+
x = linspace(-pi/2,pi/2,200)
67+
ang = pi*a*sin(x)
68+
mag = exp(-pi*a*cos(x))
69+
xret = mag*cos(ang)
70+
yret = mag*sin(ang)
71+
plt.plot(xret,yret,'k:', lw=1)
72+
an_i = -1 #int(len(xret)/2.5)
73+
an_x = xret[an_i]
74+
an_y = yret[an_i]
75+
num = '{:1.1f}'.format(a)
76+
plt.annotate("$\\frac{"+num+"\pi}{T}$", xy=(an_x, an_y), xytext=(an_x, an_y), size=8)
77+
78+
4879
# TODO: Implement more elegant cross-style axes. See:
4980
# http://matplotlib.sourceforge.net/examples/axes_grid/demo_axisline_style.html
5081
# http://matplotlib.sourceforge.net/examples/axes_grid/demo_curvelinear_grid.html
@@ -75,6 +106,10 @@ def pzmap(sys, Plot=True, title='Pole Zero Map'):
75106

76107
if (Plot):
77108
import matplotlib.pyplot as plt
109+
110+
if isdtime(sys):
111+
zgrid(plt)
112+
78113
# Plot the locations of the poles and zeros
79114
if len(poles) > 0:
80115
plt.scatter(real(poles), imag(poles), s=50, marker='x')

0 commit comments

Comments
 (0)