diff --git a/control/tests/timeresp_test.py b/control/tests/timeresp_test.py index a576d0903..54b9bc95b 100644 --- a/control/tests/timeresp_test.py +++ b/control/tests/timeresp_test.py @@ -301,17 +301,17 @@ def mimo_ss_step_matlab(self): 'SteadyStateValue': -0.5394}, {'RiseTime': 0.0000, # (*) 'SettlingTime': 3.4000, - 'SettlingMin': -0.1034, + 'SettlingMin': -0.4350, # (*) 'SettlingMax': -0.1485, 'Overshoot': 132.0170, - 'Undershoot': 79.222, # 0. in MATLAB + 'Undershoot': 0., 'Peak': 0.4350, 'PeakTime': .2, 'SteadyStateValue': -0.1875}]] - # (*): MATLAB gives 0.4 here, but it is unclear what - # 10% and 90% of the steady state response mean, when - # the step for this channel does not start a 0 for - # 0 initial conditions + # (*): MATLAB gives 0.4 for RiseTime and -0.1034 for + # SettlingMin, but it is unclear what 10% and 90% of + # the steady state response mean, when the step for + # this channel does not start a 0. return T @pytest.fixture diff --git a/control/timeresp.py b/control/timeresp.py index eafe10992..f0c130eb0 100644 --- a/control/timeresp.py +++ b/control/timeresp.py @@ -923,11 +923,11 @@ def step_info(sysdata, T=None, T_num=None, yfinal=None, else: overshoot = 0 - # Undershoot - y_us = (sgnInf * yout).min() - dy_us = np.abs(y_us) - if dy_us > 0: - undershoot = np.abs(100. * dy_us / InfValue) + # Undershoot : InfValue and undershoot must have opposite sign + y_us_index = (sgnInf * yout).argmin() + y_us = yout[y_us_index] + if (sgnInf * y_us) < 0: + undershoot = (-100. * y_us / InfValue) else: undershoot = 0