import control as ct
import numpy as np
from numpy import linalg as LA
A =[[-7, -12],
[1, 0]]
B = [1, 0]
C = [1, 2]
D = 0
sys = ct.ss(A, B, C, D)
ct.ss2tf(sys)
eigenvalues, eigenvectors = LA.eig(A)
print(eigenvalues)
print(eigenvectors)
[-4. -3.] [[-0.9701425 0.9486833 ] [ 0.24253563 -0.31622777]]
#eigenvector inverse가 제대로 되었는지 확인
inv_eigen = LA.inv(eigenvectors)
np.dot(inv_eigen, eigenvectors)
array([[1.0000000e+00, 4.4408921e-16], [0.0000000e+00, 1.0000000e+00]])
# A * x = x * lamda 확인
A_x = np.dot(A, eigenvectors) # A @ eigenvectors로 써도 같은 결과.
print("A dot eigenvector x is \n{}\n".format(A_x))
#lamda matrix 설정
lamda_matrix = [[-4, 0],[0,-3]]
x_lamda = eigenvectors@lamda_matrix
print("eigenvector dot lamda is\n{}".format(x_lamda))
A dot eigenvector x is [[ 3.88057 -2.84604989] [-0.9701425 0.9486833 ]] eigenvector dot lamda is [[ 3.88057 -2.84604989] [-0.9701425 0.9486833 ]]
#modal canonical form
#lamda = inv(eigenvector) @ A @ eigenvector
lamda_calculated = inv_eigen @ A @ eigenvectors
print("modal canonical form is \n{}".format(lamda_calculated))
modal canonical form is [[-4.00000000e+00 1.77635684e-15] [ 0.00000000e+00 -3.00000000e+00]]