def is_min_realisation(A, B, C): """ Parameters: A => state space matrix B => '' C => '' Returns: is_min_real => True if the system is the minimum realisation """ state_obsr, out_pole_vec, observe_matrix = state_observability(A, C) state_control, in_pole_vec, control_matrix = state_controllability(A, B) return state_control and state_obsr
import scipy.signal as sign from utils import state_controllability, zeros # This module executes Example 4.4. # The controllability Gramian has been included # Define state space matrices A = np.matrix([[-2, -2], [0, -4]]) B = np.matrix([[1], [1]]) C = np.matrix([[1, 0]]) D = np.matrix([[0]]) # Create frequency domain mode; G = sign.lti(A, B, C, D) control, in_vecs, c_matrix = state_controllability(A, B) # Question: Why does A.transpose give the same eigenvectors as the book # and not plain A?? # Answer: The eig function in the numpy library only calculates # the right hand eigenvectors. The Scipy library provides a eig function # in which you can specify whether you want left or right handed eigenvectors. # To determine controllability you need to calculate the input pole vectors # which is dependant on the left eigenvectors. # Calculate eigen vectors and pole vectors val, vec = LA.eig(A, None, 1, 0, 0, 0) n = lin.matrix_rank(c_matrix) P = LA.solve_continuous_lyapunov(A, -B * B.T)
from utils import state_controllability, zeros # This module executes Example 4.4. # The controllability Gramian has been included # Define state space matrices A = np.matrix([[-2, -2], [0, -4]]) B = np.matrix([[1], [1]]) C = np.matrix([[1, 0]]) D = np.matrix([[0]]) # Create frequency domain mode; G = sign.lti(A, B, C, D) control, in_vecs, c_matrix = state_controllability(A, B) # Question: Why does A.transpose give the same eigenvectors as the book # and not plain A?? # Answer: The eig function in the numpy library only calculates # the right hand eigenvectors. The Scipy library provides a eig function # in which you can specify whether you want left or right handed eigenvectors. # To determine controllability you need to calculate the input pole vectors # which is dependant on the left eigenvectors. # Calculate eigen vectors and pole vectors val, vec = LA.eig(A, None, 1, 0, 0, 0) n = lin.matrix_rank(c_matrix) P = LA.solve_lyapunov(A, -B * B.T)