Skip to content

Commit ae93195

Browse files
Merge 5c37bdf into 854f5f7
2 parents 854f5f7 + 5c37bdf commit ae93195

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

control/lti.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,14 @@ def bandwidth(self, dbdrop=-3):
211211
# solve for the bandwidth, use scipy.optimize.root_scalar() to
212212
# solve using bisection
213213
import scipy
214+
215+
if self.isdtime(strict=True):
216+
cvt_w = lambda w: np.exp(1j * w * self.dt)
217+
else:
218+
cvt_w = lambda w: 1j * w
219+
214220
result = scipy.optimize.root_scalar(
215-
lambda w: np.abs(self(w*1j)) - np.abs(dcgain)*10**(dbdrop/20),
221+
lambda w: np.abs(self(cvt_w(w))) - np.abs(dcgain)*10**(dbdrop/20),
216222
bracket=[omega[idx_dropped[0] - 1], omega[idx_dropped[0]]],
217223
method='bisect')
218224

control/tests/lti_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ def test_bandwidth(self):
109109
np.testing.assert_allclose(sys1.bandwidth(), 0.099762834511098)
110110
np.testing.assert_allclose(bandwidth(sys1), 0.099762834511098)
111111

112+
# test a first-order discrete-time system, compared with matlab
113+
sysd1 = tf([0.1, 0], [1, -0.9], 1)
114+
np.testing.assert_allclose(sysd1.bandwidth(), 0.105207775532932)
115+
np.testing.assert_allclose(bandwidth(sysd1), 0.105207775532932)
116+
112117
# test a second-order system, compared with matlab
113118
wn2 = 1
114119
zeta2 = 0.001

0 commit comments

Comments
 (0)