Skip to content

Commit fd80fc8

Browse files
committed
support discrete system as input for FRD
1 parent 92de12d commit fd80fc8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

control/frdata.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,14 @@ def __init__(self, *args, **kwargs):
110110
# the frequency range
111111
otherlti = args[0]
112112
self.omega = sort(np.asarray(args[1], dtype=float))
113-
numfreq = len(self.omega)
114113
# calculate frequency response at my points
115-
self.fresp = otherlti(1j * self.omega, squeeze=False)
114+
if otherlti.isctime():
115+
s = 1j * self.omega
116+
self.fresp = otherlti(s, squeeze=False)
117+
else:
118+
z = np.exp(1j * self.omega * otherlti.dt)
119+
self.fresp = otherlti(z, squeeze=False)
120+
116121
else:
117122
# The user provided a response and a freq vector
118123
self.fresp = array(args[0], dtype=complex)
@@ -538,7 +543,10 @@ def _convert_to_FRD(sys, omega, inputs=1, outputs=1):
538543

539544
elif isinstance(sys, LTI):
540545
omega = np.sort(omega)
541-
fresp = sys(1j * omega)
546+
if sys.isctime():
547+
fresp = sys(1j * omega)
548+
else:
549+
fresp = sys(np.exp(1j * omega * sys.dt))
542550
if len(fresp.shape) == 1:
543551
fresp = fresp[np.newaxis, np.newaxis, :]
544552
return FRD(fresp, omega, smooth=True)

0 commit comments

Comments
 (0)