JuliaControl / ControlSystems.jl

A Control Systems Toolbox for Julia
https://juliacontrol.github.io/ControlSystems.jl/stable/
Other
509 stars 85 forks source link

LsimWorkspace not working for discrete transfer functions #833

Open bryaan opened 1 year ago

bryaan commented 1 year ago

Why won't LsimWorkspace work with a discrete transfer function specified as system?

MSD = tf([2000.0],[1600.0, 40, 1])
sys = MSD

Ts = 250000
dsys = c2d(sys, Ts)

ws = LsimWorkspace(dsys, length(datetimes))
y, t, x, uout = lsim!(ws, dsys,u,t)

MethodError: no method matching LsimWorkspace(::TransferFunction{Discrete{Int64}, ControlSystemsBase.SisoRational{Float64}}, ::Int64)
Closest candidates are:
  LsimWorkspace(::AbstractStateSpace, ::Int64) at ~/.julia/packages/ControlSystemsBase/eWEYr/src/timeresp.jl:26
baggepinnen commented 1 year ago

You cannot simulate a transfer function, under the hood, transfer functions are always converted to statespace before simulation. To create the workspace, you have to convert to statespace yourself first.