Python: Python-Controlのインストール
Python-ControlをAnacondaへインストール。MATLAB互換機能がこんなに簡単にPythonで使えるようになっているとは思わなかった。
>conda install -c conda-forge control slycot
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: C:\Users\oshiro\Anaconda3
added / updated specs:
- control
- slycot
The following packages will be downloaded:
package | build
---------------------------|-----------------
ca-certificates-2020.4.5.2 | hecda079_0 184 KB conda-forge
certifi-2020.4.5.2 | py37hc8dfbb8_0 152 KB conda-forge
clangdev-5.0.0 | flang_3 189.0 MB conda-forge
conda-4.8.3 | py37hc8dfbb8_1 3.1 MB conda-forge
control-0.8.3 | py37_1 350 KB conda-forge
libblas-3.8.0 |8_h8933c1f_netlib 188 KB conda-forge
libcblas-3.8.0 |8_h8933c1f_netlib 88 KB conda-forge
libflang-5.0.0 |h6538335_20180525 519 KB conda-forge
liblapack-3.8.0 |8_h8933c1f_netlib 2.7 MB conda-forge
openmp-5.0.0 | vc14_0 576 KB conda-forge
python_abi-3.7 | 1_cp37m 4 KB conda-forge
slycot-0.4.0.0 | py37h9a9bad4_1 1.2 MB conda-forge
------------------------------------------------------------
Total: 198.0 MB
The following NEW packages will be INSTALLED:
clangdev conda-forge/win-64::clangdev-5.0.0-flang_3
control conda-forge/win-64::control-0.8.3-py37_1
libblas conda-forge/win-64::libblas-3.8.0-8_h8933c1f_netlib
libcblas conda-forge/win-64::libcblas-3.8.0-8_h8933c1f_netlib
libflang conda-forge/win-64::libflang-5.0.0-h6538335_20180525
liblapack conda-forge/win-64::liblapack-3.8.0-8_h8933c1f_netlib
openmp conda-forge/win-64::openmp-5.0.0-vc14_0
python_abi conda-forge/win-64::python_abi-3.7-1_cp37m
slycot conda-forge/win-64::slycot-0.4.0.0-py37h9a9bad4_1
The following packages will be UPDATED:
ca-certificates pkgs/main::ca-certificates-2020.1.1-0 --> conda-forge::ca-certificates-2020.4.5.2-hecda079_0
certifi pkgs/main::certifi-2020.4.5.1-py37_0 --> conda-forge::certifi-2020.4.5.2-py37hc8dfbb8_0
conda pkgs/main::conda-4.8.3-py37_0 --> conda-forge::conda-4.8.3-py37hc8dfbb8_1
The following packages will be SUPERSEDED by a higher-priority channel:
openssl pkgs/main --> conda-forge
Proceed ([y]/n)? y
Downloading and Extracting Packages
openmp-5.0.0 | 576 KB | ############################################################################ | 100%
clangdev-5.0.0 | 189.0 MB | ############################################################################ | 100%
certifi-2020.4.5.2 | 152 KB | ############################################################################ | 100%
ca-certificates-2020 | 184 KB | ############################################################################ | 100%
python_abi-3.7 | 4 KB | ############################################################################ | 100%
libcblas-3.8.0 | 88 KB | ############################################################################ | 100%
conda-4.8.3 | 3.1 MB | ############################################################################ | 100%
liblapack-3.8.0 | 2.7 MB | ############################################################################ | 100%
control-0.8.3 | 350 KB | ############################################################################ | 100%
slycot-0.4.0.0 | 1.2 MB | ############################################################################ | 100%
libblas-3.8.0 | 188 KB | ############################################################################ | 100%
libflang-5.0.0 | 519 KB | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: doneコード例
from control import matlab # MATLAB互換モジュールの読み込み import numpy as np # 数値計算モジュールの読み込み from matplotlib import pyplot as plt # グラフ描画モジュールの読み込み sys1 = matlab.tf([0, 0, 1], [0.1, 0.1, 1.0]) # 伝達関数の設定(分子、分母多項式) y1, t1 = matlab.step(sys1, T = np.arange(0, 10, 0.01)) # ステップ応答の算出(t=0~10) plt.plot(t1, y1) # 応答描画 bd = matlab.bode(sys1) # ボード線図の描画
リンク
- 「はじめての制御工学」(2018、改訂第2版、佐藤・平元・平田、講談社サイエンティフィク)
- Python Control Systems Library ? Python Control Systems Library dev documentation
- nnn112358 – Qiita
- python-control を用いたfeedback制御の基礎 – Qiita

