二阶系统时域响应曲线
import numpy as np
import matplotlib.pyplot as plt
def yt(t):
phase = np.arctan(np.sqrt(1-np.square(s))/s)
y = 1-(np.exp(-s*wn*t)/np.sqrt(1-np.square(s)))*np.sin(wn*np.sqrt(1-np.square(s))*t+phase)
return y
def baoup(t):
y = 1+(np.exp(-s*wn*t)/np.sqrt(1-np.square(s)))
return y
def baodown(t):
y = 1-(np.exp(-s*wn*t)/np.sqrt(1-np.square(s)))
return y
time = np.arange(0,4,0.01)
cyber_list = []
for i in np.arange(0.1,1,0.1):
s=i
wn=10
cyber_list.append(yt(time))
plt.figure('二阶系统')
plt.subplot(2,1,1)
for cyber in cyber_list:
plt.plot(time,cyber,color='red')
plt.ylabel('response_1')
plt.grid(True)
s=0.1
wn=10
y=yt(time)
a=baoup(time)
b=baodown(time)
plt.subplot(2,1,2)
plt.plot(time,y,color='red')
plt.plot(time,a,color='gray',linestyle='--')
plt.plot(time,b,color='gray',linestyle='--')
plt.xlabel('time')
plt.ylabel('response_2')
plt.grid(True)
plt.show()
运行结果: