Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

RuntimeWarning in impulse_response for discrete-time systems with negative real poles #1204

Open
@miroslavfikar

Description

@miroslavfikar

Description

When computing impulse responses for discrete-time systems with negative real poles,ct.impulse_response() generates aRuntimeWarning: 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:

  • np.log(-1) = 0 + πj (real part is exactly 0)
  • np.log(-2) = 0.693 + πj (real part is small)

The code attempts to compute settling time using:

t_emp=np.max(log_decay_percent/np.abs((np.log(p_nr)/dt).real))

When the real part oflog(p_nr) is zero or near-zero, this causes division by zero.

For discrete-time systems, stability and settling behavior should be based on pole magnitudes (|pole| < 1), not logarithms of negative numbers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp