Skip to content

fix impulse size for discrete-time impulse response #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 28, 2020
Merged
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
9 changes: 9 additions & 0 deletions control/tests/timeresp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,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
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,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