import numpy as np a, b, T, s, w, x, z, I = symbols('a b T s w x z I') bilinear_transform = {s: 2 / T * (z - 1) / (z + 1)} # Continuous time transfer function from I(s) to w(s) of the following plant # model: # dw/dt = a*w + b*I G_s = b / (s - a) G_z_num, G_z_den = G_s.subs(bilinear_transform).as_numer_denom() G_z_den = Poly(G_z_den, z) G_z_num = Poly(G_z_num / G_z_den.LC(), z) # divide by leading coefficient of den G_z_den = G_z_den.monic() # make denominator monic assert (G_z_den.coeffs()[0] == 1) kp = Poly(G_z_num.coeffs()[0], z) G_z_N_p = G_z_num - kp * G_z_den print(kp) print(G_z_N_p) print(G_z_den) from sympy import symbols, Poly import numpy as np a, b, T, s, w, x, z, I = symbols('a b T s w x z I') bilinear_transform = {s: 2 / T * (z - 1) / (z + 1)}
from sympy import symbols, Poly import numpy as np a, b, T, s, w, x, z, I = symbols('a b T s w x z I') bilinear_transform = {s : 2/T*(z-1)/(z+1)} # Continuous time transfer function from I(s) to w(s) of the following plant # model: # dw/dt = a*w + b*I G_s = b/(s-a) G_z_num, G_z_den = G_s.subs(bilinear_transform).as_numer_denom() G_z_den = Poly(G_z_den, z) G_z_num = Poly(G_z_num / G_z_den.LC(), z) # divide by leading coefficient of den G_z_den = G_z_den.monic() # make denominator monic assert(G_z_den.coeffs()[0] == 1) kp = Poly(G_z_num.coeffs()[0], z) G_z_N_p = G_z_num - kp * G_z_den print(kp) print(G_z_N_p) print(G_z_den) from sympy import symbols, Poly import numpy as np a, b, T, s, w, x, z, I = symbols('a b T s w x z I') bilinear_transform = {s : 2/T*(z-1)/(z+1)}