In [ ]:
import numpy as np
import matplotlib.pyplot as plt
%pylab inline
In [ ]:
import modred
import control as con
In [ ]:
K = 1
d = 0.5
T = 10
delay = 10
a0 = 1
a1 = (2 * d * T) #16
a2 = (T**2) #100
b0 = K
tf_1 = con.matlab.tf(K, [a2, a1, a0])
#print tf_1
ss_1a = con.matlab.tf2ss(tf_1)
#print ss_1a
d_num, d_den = con.pade(delay, 1)
tf_delay = con.tf(d_num, d_den)
ss_delay = con.series(tf_delay, tf_1)
#print con.matlab.tf2ss(ss_delay)
In [ ]:
d_yout, d_T = con.matlab.step(ss_delay)
yout, T = con.matlab.step(tf_1) # step without delay
plt.plot(d_T, d_yout, 'r-', label='poly_est')
plt.plot(np.add(d_T, delay), yout, 'g-', label='idealized') #delay in timeaxis!
In [ ]:
#http://pythonhosted.org/modred/
markov_est = modred.okid.OKID(np.ones(yout.size), yout, yout.size/2)
num_states = 10
myERA = modred.era.ERA()
A, B, C=modred.era.compute_ERA_model(markov_est, num_states)
ss_est = con.ss(A, B, C, 0)
print ss_est
#con.matlab.bode(ss)
yout, T = con.matlab.step(ss_est) # step without delay
print yout
plt.plot(T, yout, 'r-', label='y_est')
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: