@@ -99,17 +99,21 @@ function ControlSystemsBase.tf(sys::Sym, h = nothing)
9999end
100100
101101function expand_coeffs (n, var; numeric = false )
102- n = sp. Poly (n, var)
103- deg = n. degree () |> Float64 |> Int
104- c = n. all_coeffs () # This fails if the coeffs are symbolic
105- numeric && (c = Float64 .(c))
106- [c; zeros (eltype (c), deg - length (c) + 1 )]
102+ if n == 0
103+ [0.0 ]
104+ else
105+ n = sp. Poly (n, var)
106+ deg = n. degree () |> Float64 |> Int
107+ c = n. all_coeffs () # This fails if the coeffs are symbolic
108+ numeric && (c = Float64 .(c))
109+ [c; zeros (eltype (c), deg - length (c) + 1 )]
110+ end
107111end
108112expand_coeffs (n:: Real , args... ; numeric = false ) = n
109113
110114function ControlSystemsBase. tf (sys:: NumOrDiv , h = nothing )
111- sp = Symb. symbolics_to_sympy (sys)
112- G = tf (sp , h)
115+ sys_sp = Symb. symbolics_to_sympy (sys)
116+ G = h === nothing || h === Continuous () ? tf (sys_sp) : tf (sys_sp , h)
113117 tf (to_num .(numvec (G)[]), to_num .(denvec (G)[]), G. timeevol)
114118end
115119
@@ -144,7 +148,8 @@ function to_num(x::Sym)::Num
144148 try
145149 return Float64 (x)
146150 catch
147- Symb. Num (Symb. variable (Symbol (x); T= Real))
151+ # Symb.Num(Symb.variable(Symbol(x); T=Real))
152+ Symb. parse_expr_to_symbolic (Meta. parse (string (x)), Main)
148153 end
149154end
150155
0 commit comments