You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RuntimeWarning in impulse_response for discrete-time systems with negative real poles #1204
When computing impulse responses for discrete-time systems with negative real poles, ct.impulse_response() generates a RuntimeWarning: divide by zero encountered in divide. This occurs even though the system is valid and the results are correct.
Minimal Reproducible Example
importcontrolasctimportnumpyasnp# Discrete-time system with poles at -1 and -2b, a= [1, 3, 0], [1, 3, 2]
sys=ct.TransferFunction(b, a, dt=True)
# This triggers the warningt, y=ct.impulse_response(sys, 5)
Output:
RuntimeWarning: divide by zero encountered in divide
t_emp = np.max(log_decay_percent / np.abs((np.log(p_nr)/dt).real))
Root Cause
The warning originates from the settling time calculation in the time response functions. For negative real poles in discrete-time systems:
Activity
2 fixes. 1st fix: the m_nr branch which is meant to handle negative r…
2 fixes. 1st fix: the m_nr branch which is meant to handle negative r…
2 fixes. 1st fix: the m_nr branch which is meant to handle negative r…
Fix negative real handling for tfinal of discrete-time systems