Skip to content

Commit 7a135d1

Browse files
authored
Merge pull request #1023 from KybernetikJo/fix_impulse_response
Fix impuse response, input data only contains one input[0]==1 in each trace
2 parents 5ba44b5 + 7624aeb commit 7a135d1

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

control/tests/timeresp_test.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,32 @@ def test_discrete_time_impulse(self, tsystem):
536536
sysdt = sys.sample(dt, 'impulse')
537537
np.testing.assert_array_almost_equal(impulse_response(sys, t)[1],
538538
impulse_response(sysdt, t)[1])
539+
540+
def test_discrete_time_impulse_input(self):
541+
# discrete time impulse input, Only one active input for each trace
542+
A = [[.5, 0.25],[.0, .5]]
543+
B = [[1., 0,],[0., 1.]]
544+
C = [[1., 0.],[0., 1.]]
545+
D = [[0., 0.],[0., 0.]]
546+
dt = True
547+
sysd = ct.ss(A,B,C,D, dt=dt)
548+
response = ct.impulse_response(sysd,T=dt*3)
549+
550+
Uexpected = np.zeros((2,2,4), dtype=float).astype(object)
551+
Uexpected[0,0,0] = 1./dt
552+
Uexpected[1,1,0] = 1./dt
553+
554+
np.testing.assert_array_equal(response.inputs,Uexpected)
555+
556+
dt = 0.5
557+
sysd = ct.ss(A,B,C,D, dt=dt)
558+
response = ct.impulse_response(sysd,T=dt*3)
559+
560+
Uexpected = np.zeros((2,2,4), dtype=float).astype(object)
561+
Uexpected[0,0,0] = 1./dt
562+
Uexpected[1,1,0] = 1./dt
563+
564+
np.testing.assert_array_equal(response.inputs,Uexpected)
539565

540566
@pytest.mark.parametrize("tsystem", ["siso_ss1"], indirect=True)
541567
def test_impulse_response_warnD(self, tsystem):

control/timeresp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,7 +2013,7 @@ def impulse_response(
20132013
yout[:, inpidx, :] = response.y if output is None \
20142014
else response.y[output]
20152015
xout[:, inpidx, :] = response.x
2016-
uout[:, inpidx, :] = U[i]
2016+
uout[:, inpidx, :] = U if input is None else U[i]
20172017

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy