[SciPy-user] problem with lsim

Ryan Krauss ryanlists at gmail.com
Mon Nov 27 22:36:16 CST 2006


I am having a problem with signal.lsim.  Here is a script that
recreates my problem:

from scipy import *
from pylab import plot

t=arange(0,10,0.01)
u=ones(shape(t))
sys=signal.lti([1.0],[1.0,1.0])
out=signal.lsim(sys,u,t)
plot(out[0],out[1])

Here is the error message:
I:\lsim_test.py
      5 u=ones(shape(t))
      6 sys=signal.lti([1.0],[1.0,1.0])
----> 7 out=signal.lsim(sys,u,t)
      8 plot(out[0],out[1])
      9

c:\python24\lib\site-packages\scipy\signal\ltisys.py in lsim(system, U, T, X0, i
nterp)
    403     vt = transpose(v)
    404     vti = linalg.inv(vt)
--> 405     GT = dot(dot(vti,diag(numpy.exp(dt*lam))),vt).astype(xout.dtype.char
)
    406     ATm1 = linalg.inv(AT)
    407     ATm2 = dot(ATm1,ATm1)

C:\Python24\Lib\site-packages\numpy\lib\twodim_base.py in diag(v, k)
     66             i = arange(0,n+k)
     67             fi = i+(i-k)*n
---> 68         res.flat[fi] = v
     69         return res
     70     elif len(s)==2:

TypeError: can't convert complex to float; use abs(z)
WARNING: Failure executing file: <lsim_test.py>

My script is also attached if someone wants to run it.

How do I fix this?

Thanks,

Ryan
-------------- next part --------------
from scipy import *
from pylab import plot

t=arange(0,10,0.01)
u=ones(shape(t))
sys=signal.lti([1.0],[1.0,1.0])
out=signal.lsim(sys,u,t)
plot(out[0],out[1])


More information about the SciPy-user mailing list