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?

[Python]伝達関数の時間応答を計算するスクリプト

Last updated at Posted at 2024-08-03

時間応答はStep応答やインテンシャル応答ではない、任意の入力に対する応答。lsimを使用する。

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

# 初期条件
x0 = [0, 0]

# 時間配列
t =  np.arange(0, 3, 0.01)

# 正弦波入力
freq = 0.5
amp = 1.0
u = amp * np.sin(2 * np.pi * freq * t)

# 伝達関数モデル
s = tf('s')
P = 1/(s**2+2*0.3*s+1)

# lsimで応答計算
(y1a, T1a, x1a) = lsim(P, U=u, T=t, X0=x0)

# グラフ表示
plt.axhline(0, color="b", linestyle="--")
plt.plot(T1a, u, label="Input")
plt.plot(T1a, y1a, label="Output")
plt.xlabel("Time (s)")
plt.ylabel("Displacement")
plt.title("Response to Sinusoidal Input")
plt.legend()
plt.grid(True)
plt.show()

実行結果
出力例.png

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?