Skip to content

Commit

Permalink
Merge pull request #447 from sawyerbfuller/fix-dt-impulse-size
Browse files Browse the repository at this point in the history
fix impulse size for discrete-time impulse response
  • Loading branch information
bnavigator committed Dec 28, 2020
2 parents 37d1121 + 0b85e3b commit daf2536
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions control/tests/timeresp_test.py
Expand Up @@ -218,6 +218,15 @@ def test_impulse_response(self):
np.testing.assert_array_almost_equal(
yy, np.vstack((youttrue, np.zeros_like(youttrue))), decimal=4)

def test_discrete_time_impulse(self):
# discrete time impulse sampled version should match cont time
dt = 0.1
t = np.arange(0, 3, dt)
sys = self.siso_tf1
sysdt = sys.sample(dt, 'impulse')
np.testing.assert_array_almost_equal(impulse_response(sys, t)[1],
impulse_response(sysdt, t)[1])

def test_initial_response(self):
# Test SISO system
sys = self.siso_ss1
Expand Down
2 changes: 1 addition & 1 deletion control/timeresp.py
Expand Up @@ -822,7 +822,7 @@ def impulse_response(sys, T=None, X0=0., input=0, output=None, T_num=None,
new_X0 = B + X0
else:
new_X0 = X0
U[0] = 1.
U[0] = 1./sys.dt # unit area impulse

T, yout, _xout = forced_response(sys, T, U, new_X0, transpose=transpose,
squeeze=squeeze)
Expand Down

0 comments on commit daf2536

Please sign in to comment.