In [1]:
import numpy as np
import sympy as sy
import matplotlib.pyplot as plt
import control.matlab as cm
%matplotlib inline
In [2]:
np.log(2)/2.0
Out[2]:
In [10]:
Hc = cm.tf([1],[1, 0], np.log(2)/2.0)
Hc
Out[10]:
In [9]:
Td = np.log(2)/2*np.arange(20)
(yd,td) = cm.step(Hc, Td)
plt.plot(td,yd[0], '*')
plt.xlim([0,8])
plt.ylim([0,1.4])
plt.savefig("step-dead-beat.pdf")
In [13]:
b = (2-np.sqrt(2))/2.0
a1 = -(3*np.sqrt(2)-2)/2.0
a2 = (2*np.sqrt(2)-2)/2.0
Hc2 = cm.tf([2*b, -b], [1, a1, a2], np.log(2)/4.0)
Td2 = np.log(2)/4*np.arange(40)
(yd2,td2) = cm.step(Hc2, Td2)
plt.plot(td,yd[0], '*')
plt.plot(td2,yd2[0], 'r*')
plt.xlim([-0.2,8])
plt.ylim([-0.2,1.4])
plt.savefig("step-half-sampling-time.pdf")
In [19]:
cm.feedback?
In [41]:
H = cm.tf([0.5],[1, -0.5], np.log(2)/2.0)
F = 1.05*cm.tf([2, -1],[1, -1], np.log(2)/2.0)
FH = F*H
Hcl = cm.feedback(FH)
print Hcl
Hcu = cm.feedback(F, H)
print Hcu
In [42]:
Td = np.log(2)/2*np.arange(20)
(yd,td) = cm.step(Hcl, Td)
(ud,td) = cm.step(Hcu, Td)
plt.plot(td,yd[0], '*')
plt.plot(td,ud[0], 'r*')
plt.xlim([-0.2,8])
plt.ylim([-0.2,3.1])
plt.savefig("step-dead-beat.pdf")
In [22]:
ud
Out[22]:
In [ ]: