python - SciPy step response plot seems to break for some values -


i'm using scipy instead of matlab in control systems class plot step responses of lti systems. it's worked great far, i've run issue specific system. code:

from numpy import min scipy import linspace scipy.signal import lti, step matplotlib import pyplot p  # create lti transfer function coefficients tf = lti([64], [1, 16, 64]) # step response (redo better resolution) t, s = step(tf) t, s = step(tf, t = linspace(min(t), t[-1], 200)) # plotting stuff p.plot(t, s) p.xlabel('time / s') p.ylabel('displacement / m') p.show() 

the code as-is displays flat line. if modify final coefficient of denominator 64.00000001 (i.e., tf = lti([64], [1, 16, 64.0000001])) works should, showing underdamped step response. setting coefficient 63.9999999 works. changing coefficients have explicit decimal places (i.e., tf = lti([64.0], [1.0, 16.0, 64.0])) doesn't affect anything, guess it's not case of integer division messing things up.

is bug in scipy, or doing wrong?

this limitation of implementation of step function. uses matrix exponential find step response, , doesn't handle repeated poles well. (your system has repeated pole @ -8.)

instead of using step, can use function scipy.signal.step2

in [253]: scipy.signal import lti, step2  in [254]: sys = lti([64], [1, 16, 64])  in [255]: t, y = step2(sys)  in [256]: plot(t, y) out[256]: [<matplotlib.lines.line2d @ 0x5ec6b90>] 

enter image description here


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -