8000 Merge pull request #447 from sawyerbfuller/fix-dt-impulse-size · python-control/python-control@daf2536 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit daf2536

Browse files
authored
Merge pull request #447 from sawyerbfuller/fix-dt-impulse-size
fix impulse size for discrete-time impulse response
2 parents 37d1121 + 0b85e3b commit daf2536

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

control/tests/timeresp_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ def test_impulse_response(self):
218218
np.testing.assert_array_almost_equal(
219219
yy, np.vstack((youttrue, np.zeros_like(youttrue))), decimal=4)
220220

221+
def test_discrete_time_impulse(self):
222+
# discrete time impulse sampled version should match cont time
223+
dt = 0.1
224+
t = np.arange(0, 3, dt)
225+
sys = self.siso_tf1
226+
sysdt = sys.sample(dt, 'impulse')
227+
np.testing.assert_array_almost_equal(impulse_response(sys, t)[1],
228+
impulse_response(sysdt, t)[1])
229+
221230
def test_initial_response(self):
222231
# Test SISO system
223232
sys = self.siso_ss1

control/timeresp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ def impulse_response(sys, T=None, X0=0., input=0, output=None, T_num=None,
822822
new_X0 = B + X0
823823
else:
824824
new_X0 = X0
825-
U[0] = 1.
825+
U[0] = 1./sys.dt # unit area impulse
826826

827827
T, yout, _xout = forced_response(sys, T, U, new_X0, transpose=transpose,
828828
squeeze=squeeze)

0 commit comments

Comments
 (0)
0