Skip to content

Commit de38612

Browse files
committed
fix bug in the way inputs were stored for MIMO step_response
1 parent 9023de9 commit de38612

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

control/tests/timeresp_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,15 @@ def test_step_response_mimo(self, tsystem):
344344
np.testing.assert_array_almost_equal(y_00, yref, decimal=4)
345345
np.testing.assert_array_almost_equal(y_11, yref, decimal=4)
346346

347+
# Make sure we get the same result using MIMO step response
348+
response = step_response(sys, T=t)
349+
np.testing.assert_allclose(response.y[0, 0, :], y_00)
350+
np.testing.assert_allclose(response.y[1, 1, :], y_11)
351+
np.testing.assert_allclose(response.u[0, 0, :], 1)
352+
np.testing.assert_allclose(response.u[1, 0, :], 0)
353+
np.testing.assert_allclose(response.u[0, 1, :], 0)
354+
np.testing.assert_allclose(response.u[1, 1, :], 1)
355+
347356
@pytest.mark.parametrize("tsystem", ["mimo_ss1"], indirect=True)
348357
def test_step_response_return(self, tsystem):
349358
"""Verify continuous and discrete time use same return conventions."""

control/timeresp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ def step_response(sys, T=None, X0=0, input=None, output=None, T_num=None,
13631363
yout[:, inpidx, :] = response.y if output is None \
13641364
else response.y[output]
13651365
xout[:, inpidx, :] = response.x
1366-
uout[:, inpidx, :] = U[i]
1366+
uout[:, inpidx, :] = U if input is None else U[i]
13671367

13681368
# Figure out if the system is SISO or not
13691369
issiso = sys.issiso() or (input is not None and output is not None)

0 commit comments

Comments
 (0)