using ControlSystems Np = [0, 1] # 伝達関数の分子多項式の係数 (0*s + 1) Dp = [1, 2, 3] # 伝達関数の分母多項式の係数 (1*s^2 + 2*s + 3) P = tf(Np, Dp) P = tf([0, 1], [1, 2, 3]) s = tf("s") P = 1/(s^2+2s+3) P = tf([1, 2], [1, 5, 3, 4]) using Symbolics @variables s expand( (s+1)*(s+2)^2 ) P = tf([1, 3],[1, 5, 8, 4]) P1 = tf([1, 3], [0, 1]) P2 = tf([0, 1], [1, 1]) P3 = tf([0, 1], [1, 2]) P = P1 * P2 * P3^2 s = tf("s") P = 1/(s+1)/(s+2)^2 den(P) num(P) A = [0 1; -1 -1] B = [0; 1] C = [1 0] D = 0 P = ss(A, B, C, D) A = [1 1 2; 2 1 1; 3 4 5] B = [2; 0; 1] C = [1 1 0] D = 0 P = ss(A, B, C, D) println("A=", P.A) println("B=", P.B) println("C=", P.C) println("D=", P.D) sysA, sysB, sysC, sysD = ssdata(P) println("A=", sysA) println("B=", sysB) println("C=", sysC) println("D=", sysD) S1 = tf( [0, 1], [1, 1]) S2 = tf( [1, 1], [1, 1, 1]) S = S2 * S1; println(S) S = series(S1, S2); println(S) minreal(S) S = S1 + S2; println(S) S = parallel(S1, S2) println(S) S = S1*S2 / (1 + S1*S2) println(S) S = feedback(S1*S2, 1) println(S) minreal(S) S1 = tf(1, [1, 1]) S2 = tf(1, [1, 2]) S3 = tf([3, 1], [1, 0]) S4 = tf([2, 0], [0, 1]) S12 = feedback(S1, S2) S123 = series(S12, S3) S = feedback(S123, S4) P = tf( [0, 1], [1, 1, 1]) Pss = ss(P) # 伝達関数モデルから状態空間モデルへの変換 println(Pss) Ptf = tf(Pss) # 状態空間モデルから伝達関数モデルへの変換 println(Ptf) S1 = tf([1, 1], [0, 1]) S2 = tf([0, 1], [1, 1]) S = series(S1, S2) minreal(S) print(S2) ss(S2) print(S1) ss(S1)