From a709dd60e958be17bf748143ad764328ba007542 Mon Sep 17 00:00:00 2001 From: aWZHY0yQH81uOYvH <32046476+aWZHY0yQH81uOYvH@users.noreply.github.com> Date: Thu, 12 Mar 2026 22:13:00 -0700 Subject: [PATCH] fix bandwidth function for DT systems --- control/lti.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/control/lti.py b/control/lti.py index e4c9b2f4e..90188f556 100644 --- a/control/lti.py +++ b/control/lti.py @@ -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')