0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pythonで伝達関数のステップ応答を計算する

Last updated at Posted at 2022-09-01

伝達関数の出力の計算

controlパッケージの、lsim関数を用いる。
入力値と出力値が表示されるプログラムになっている。

from control.matlab import *
import numpy as np
import matplotlib.pyplot as plt

#伝達関数の準備
N = [200] #分子
D = [1,5,20] #分母
trans = tf(N,D)
print(trans)

#時間データの準備
t = np.linspace(0,10,1000)

#入力データの準備
u = []
for i in range(0,len(t)):
    if 3<t[i]<7:
        u.append(1)
    else:
        u.append(0)

#出力データの計算
y, T,x = lsim(trans, u, t)

plt.plot(T,y)#出力
plt.plot(T,u)#入力
plt.show()
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?