import numpy as np import control # %% Model params: m = 10 # [kg] k = 4 # [N/m] d = 2 # [N/(m/s)] # %% System matrices as 2D arrays: A = np.array([[0, 1], [-k/m, -d/m]]) B = np.array([[0], [1/m]]) D = np.array([[0]]) # %% Creating the state space model with x1 as output: C1 = np.array([[1, 0]]) S1 = control.ss(A, B, C1, D) # %% Deriving transfer function H1 from S1: H1 = control.ss2tf(S1) # %% Displaying H1: print('H1 =', H1) # %% Creating the state space model with x2 as output: C2 = np.array([[0, 1]]) S2 = control.ss(A, B, C2, D) # %% Deriving transfer function H2 from S2: H2 = control.ss2tf(S2) # %% Displaying H1: print('H2 =', H2)