Pythonで制御系設計1

なんだかんだで 一応開始。ただし教科書は

もう一度おさらいでの

制御のためのMATLAB 尾形克彦著 東京電機大学出版局

にします。

今回は2章から

伝達関数の分母分子の多項式を部分分数展開する方法です。

例題2−1では以下pythonでの記述ですが

num=np.array([2,5,3,6]):matlab:num=[2 5 3 6]

den=np.array([1,6,11,6]):matlab:den=[1 611 6]

すなわち伝達関数

B(s)=2s^3+5s^2+3s+6

ーー  ーーーーーーーーーーーー

A(s)=s^3+6s^2+11s+6

という形を部分分数展開するもので

pythonではfrom control.matlab import *

を使いmatlabのコマンドするのではなく(というかここには無い)

scipyにあるのでした。

scipy.signal.residue

from control.matlab import * <これにはなし
import matplotlib.pyplot as plt <使ってない
import numpy as np
import scipy as sp   <これ

num=np.array([2,5,3,6])
den=np.array([1,6,11,6])
[r,p,k]=sp.signal.residue(num,den)
print(r)
print(p)
print(k)

まわりくどいプログラムですが

結果は

[ 3. -4. -6.]
[-1. -2. -3.]
[2.]

と出ました。

-6       -4           3                  

—- + —-  +  —-           +2

s+3    s+2       s+1

ということです。

control.matlabだけでなくscipyも駆使していくことになりそうです。

https://blog.goo.ne.jp/murano-brain/c/f57dd3de771f591d65a27b39288c0ba4

コメント

  1. First off I would like to say wonderful blog! I
    had a quick question which I’d like to ask if you don’t mind.
    I was curious to find out how you center yourself and clear your
    thoughts before writing. I’ve had a tough time clearing
    my thoughts in getting my ideas out there. I truly do take pleasure in writing
    but it just seems like the first 10 to 15 minutes tend to be lost just trying to figure out how to begin. Any suggestions or tips?

    Thank you!

タイトルとURLをコピーしました