【问题标题】:With control.step_response can't get the expected output使用 control.step_response 无法获得预期的输出
【发布时间】:2021-03-26 12:52:05
【问题描述】:
import control
import numpy as np
import matplotlib.pyplot as plt
Ts = 1
G1 = control.tf([60], [1,0.1])
G2 = control.tf([0.5, 3], [1, 5, 12])
G3 = control.tf([1], [1, 5])
Gs= G1*G2*G3
Gz = control.c2d(Gs,Ts, method='tustin' )

print(Gz)
print(Gs)

cltf=(Gs/(1+Gs))
Zcltf=(Gz/(1+Gz))

T = np.arange(0, 15)
za = control.step_response(cltf, T)
Tout, y = control.step_response(cltf, T)
Tout, x = control.step_response(Zcltf, T) 

plt.subplot(2,1,1)
plt.plot(Tout, y)
plt.subpolt(2,1,2)
plt.plot(Tout,y.Tout)

大家好,这是我的代码。我是 Python 新手。我的步骤响应总是这样:This Graph

在 Matlab 中,我得到了两步响应 Like those

不知道是什么原因。

【问题讨论】:

    标签: python python-control


    【解决方案1】:

    时间向量 T 需要更多的点,如果你不放 step 使用 de 默认值。你可以试试 whiht T = np.arange(0, 15,0.1)。

    另一方面,如果你没有在函数step_response中使用T来计算一个时间向量,但是对一些植物有一些问题,例如,僵硬的植物。

    试试这个:

    Tout, y = control.step_response(cltf)
    

    最后,你永远不会绘制 x(数字阶梯输出),你可以尝试使用 plt.step() 代替 plt.plot() 来绘制阶梯图。

    import control
    import numpy as np
    import matplotlib.pyplot as plt
    Ts = 1
    G1 = control.tf([60], [1,0.1])
    G2 = control.tf([0.5, 3], [1, 5, 12])
    G3 = control.tf([1], [1, 5])
    Gs= G1*G2*G3
    Gz = control.c2d(Gs,Ts, method='tustin' )
    
    print(Gz)
    print(Gs)
    
    cltf=(Gs/(1+Gs))
    Zcltf=(Gz/(1+Gz))
    
    Tout1, y = control.step_response(cltf)
    Tout2, x = control.step_response(Zcltf) 
    
    
    plt.plot(Tout1, y)
    plt.figure()
    plt.step(Tout2,x)
    

    【讨论】:

      猜你喜欢
      • 2021-08-31
      • 2021-06-25
      • 1970-01-01
      • 2019-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-11
      相关资源
      最近更新 更多