예제 12.1
import control as ctrl
import matplotlib.pyplot as plt
import numpy as np
import sympy
import math
from sympy import Matrix
from sympy import I
s = sympy.Symbol('s')
num_poly = 20*(s+5)
den_poly = s*(s+1)*(s+4)
num_polynomial = sympy.expand(num_poly)
den_polynomial = sympy.expand(den_poly)
num_poly
num = []
num.append(float(num_polynomial.coeff(s,1)))
num.append(float(num_polynomial.coeff(s,0)))
den = []
den.append(float(den_polynomial.coeff(s,3)))
den.append(float(den_polynomial.coeff(s,2)))
den.append(float(den_polynomial.coeff(s,1)))
den.append(float(den_polynomial.coeff(s,0)))
system = ctrl.TransferFunction(num, den)
system
state_space = ctrl.tf2ss(system)
state_space
A = Matrix(state_space.A)
B = Matrix(state_space.B)
k1, k2, k3 = sympy.symbols('k1 k2 k3')
identity_matrix = np.identity(3)
k = Matrix([k1, k2, k3])
k = k.reshape(1, 3)
sABK = s*identity_matrix-A+B@k
sABK.det()
poly_nomial = (s+5.1)*(s+5.4+I*7.2)*(s+5.4-I*7.2)
polynomial = sympy.expand(poly_nomial)
polynomial