Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion control/lti.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,14 @@ def bandwidth(self, dbdrop=-3):
# solve for the bandwidth, use scipy.optimize.root_scalar() to
# solve using bisection
import scipy

if self.isdtime(strict=True):
cvt_w = lambda w: np.exp(1j * w * self.dt)
else:
cvt_w = lambda w: 1j * w

result = scipy.optimize.root_scalar(
lambda w: np.abs(self(w*1j)) - np.abs(dcgain)*10**(dbdrop/20),
lambda w: np.abs(self(cvt_w(w))) - np.abs(dcgain)*10**(dbdrop/20),
bracket=[omega[idx_dropped[0] - 1], omega[idx_dropped[0]]],
method='bisect')

Expand Down
5 changes: 5 additions & 0 deletions control/tests/lti_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ def test_bandwidth(self):
np.testing.assert_allclose(sys1.bandwidth(), 0.099762834511098)
np.testing.assert_allclose(bandwidth(sys1), 0.099762834511098)

# test a first-order discrete-time system, compared with matlab
sysd1 = tf([0.1, 0], [1, -0.9], 1)
np.testing.assert_allclose(sysd1.bandwidth(), 0.105207775532932)
np.testing.assert_allclose(bandwidth(sysd1), 0.105207775532932)

# test a second-order system, compared with matlab
wn2 = 1
zeta2 = 0.001
Expand Down