# eigenvector example import numpy as np import matplotlib.pyplot as plt from scipy import signal a = np.array([[-1,-10,-10],[1,0,0],[0,1,0]],dtype=float) b = np.array([[0],[0],[0]],dtype=float) c = np.eye(3) d = np.zeros((3,1)) sys = signal.StateSpace(a, b, c, d) t, yout, xout = signal.lsim(sys, U=0, T=np.linspace(0,10,100), X0=[0,-1,1]) plt.figure(figsize=(8,4), dpi=100) plt.plot(t,xout) plt.grid() plt.show() # (right) eigenvectors D,V = np.linalg.eig(a) print(f'eval_r:\n{D}') print(f'evec_r:\n{V}') # left eigenvectors D,W = np.linalg.eig(a.T) print(f'eval_l:\n{D}') print(f'evec_l:\n{W}') # w3: left eigenvector associated with lambda=-1 w3 = W[:,2] print(f'w3:\n{w3}') # (w_3^T)x history plt.figure(figsize=(8,4), dpi=100) plt.plot(t,xout.dot(w3)) plt.grid() plt.show() # time history for x_0 = V[:,0].real t, yout, xout = signal.lsim(sys, U=0, T=np.linspace(0,10,100), X0=V[:,0].real) plt.figure(figsize=(8,4), dpi=100) plt.plot(t,xout) plt.grid() plt.show()