0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

2階線形微分方程式のメモ

Last updated at Posted at 2024-12-15

image.png

https://www.shinshu-u.ac.jp/faculty/engineering/appl/NOW/kenkyu/ohno/note09/appl1-13.pdf
MATLAB/Simulink
image.png

image.png

import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp

# 微分方程式のパラメータ
a = 1  # 2次の係数
b = 2  # 1次の係数
c = 3  # 定数項の係数
C0 = 0  # 初期条件 x(0)
C1 = 0  # 初期条件 x'(0)

# ステップ入力の定義
def step_input(t):
    return 1 if t >= 0 else 0

# 微分方程式を定義
def diff_eq(t, y):
    x, dx = y  # y[0] = x(t), y[1] = x'(t)
    f_t = step_input(t)  # ステップ入力
    ddx = (f_t - b * dx - c * x) / a  # 2次微分の計算
    return [dx, ddx]

# 時間範囲の設定
t_span = (0, 10)  # 0秒から10秒まで
t_eval = np.linspace(0, 10, 1000)  # 時間の分割

# 初期条件
y0 = [C0, C1]  # x(0) = C0, x'(0) = C1

# 数値解を求める
solution = solve_ivp(diff_eq, t_span, y0, t_eval=t_eval)

# 結果のプロット
plt.figure(figsize=(8, 6))
plt.plot(solution.t, solution.y[0], label='x(t)', color='blue')
plt.axhline(1, color='red', linestyle='--', label='Step Input f(t)')
plt.title('Response of the System to a Step Input')
plt.xlabel('Time t')
plt.ylabel('x(t)')
plt.legend()
plt.grid()
plt.show()

image.png

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?