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
11 changes: 11 additions & 0 deletions control/tests/timeresp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,17 @@ def test_response_transpose(
assert y.shape == ysh_no
assert x.shape == (T.size, sys.nstates)

def test_forced_response_transpose_without_time_vector(self):
sys = ct.ss(
[[0.5]], [[1.0, -0.25]], [[1.0]], [[0.0, 0.0]], dt=True)
U = np.column_stack((np.arange(5.0), np.arange(5.0) + 10))

response = ct.forced_response(sys, inputs=U, transpose=True)

np.testing.assert_allclose(response.time, np.arange(U.shape[0]))
np.testing.assert_allclose(response.inputs, U)
assert response.outputs.shape == (U.shape[0], sys.noutputs)


@pytest.mark.pandas
def test_to_pandas():
Expand Down
2 changes: 1 addition & 1 deletion control/timeresp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ def forced_response(
raise ValueError('Parameters `T` and `U` can\'t both be '
'zero for discrete-time simulation')
# Set T to equally spaced samples with same length as U
if U.ndim == 1:
if U.ndim == 1 or transpose:
n_steps = U.shape[0]
else:
n_steps = U.shape[1]
Expand Down