@@ -196,6 +196,14 @@ function lsim(sys::AbstractStateSpace, u::AbstractVecOrMat, t::AbstractVector;
196196 error (" Time vector t must be uniformly spaced" )
197197 end
198198
199+ # Handle pure D system (no states)
200+ if nx == 0
201+ x = Matrix {eltype(u)} (undef, 0 , length (t)) # no states
202+ y = sys. D * u
203+ dsys = sys
204+ return SimResult (y, t, x, u, dsys)
205+ end
206+
199207 if iscontinuous (sys)
200208 if method === :zoh
201209 dsys = c2d (sys, dt, :zoh )
@@ -280,6 +288,18 @@ function lsim(sys::AbstractStateSpace, u::Function, t::AbstractVector;
280288
281289 dt = t[2 ] - t[1 ]
282290
291+ # Handle pure D system (no states)
292+ if nx == 0
293+ uout = Matrix {T} (undef, nu, length (t))
294+ for i = 1 : length (t)
295+ uout[:, i] = u (T[], t[i])
296+ end
297+ x = Matrix {T} (undef, 0 , length (t)) # no states
298+ y = sys. D * uout
299+ simsys = sys
300+ return SimResult (y, t, x, uout, simsys)
301+ end
302+
283303 if ! iscontinuous (sys) || method ∈ (:zoh , :tustin , :foh , :fwdeuler )
284304 if iscontinuous (sys)
285305 simsys = c2d (sys, dt, method)
0 commit comments