Pythonモジュール「SciPy」でRLC回路のボード線図・位相線図を描く方法をソースコード付きでまとめました。
【RLC回路】ボード線図・位相線図
Pythonモジュール「SciPy」でRLC回路のボード線図・位相線図を描いてみます。
■RLC回路の伝達関数
(1) ![]()
ソースコード(Python3 + SciPy + NumPy)
サンプルプログラムのソースコードです。
# -*- coding: utf-8 -*-
from scipy import signal
import matplotlib.pyplot as plt
# RLC回路のパラメータ
R = 100
L = 0.1
C = 0.001
# 伝達関数の定義
num = [1] # 分子の係数
den = [L*C, R*C, 1] # 分母の係数
G = signal.lti(num, den)
# ボード線図の計算
w, mag, phase = signal.bode(G)
# ゲイン線図の描画
plt.subplot(2, 1, 1)
plt.semilogx(w, mag)
plt.ylabel("Gain[dB]")
plt.grid()
# 位相線図の描画
plt.subplot(2, 1, 2)
plt.semilogx(w, phase)
plt.xlabel("w[rad/sec]")
plt.ylabel("Phase[deg]")
plt.grid()
plt.show()
実行結果
サンプルプログラムの実行結果です。

| – | 関連記事 |
|---|---|
| 1 | ■【SciPy入門】科学技術計算の使い方 |
| 2 | ■Python入門 基本文法 |

コメント