# [SciPy-user] signal.lti

Ryan Krauss ryanlists at gmail.com
Thu Sep 7 21:55:29 CDT 2006

```I am having a rough time trying to use the lti portion of
scipy.signal.  For starters, I just wanted to generate a step response
for an integrator (1/s).  I tried creating this system two ways, and
neither seems to work correctly.  I think this system has a numerator
of 1 and a denominator of [1,0].  If I create the system based on the
num, den I get:
In [51]: mysys=scipy.signal.lti(1,[1,0])

In [52]: mysys.A
Out[52]: NumPy array, format: long
[[-0.]]

In [53]: mysys.B
Out[53]: NumPy array, format: long
[[1]]

In [54]: mysys.C
Out[54]: NumPy array, format: long
[[ 1.]]

In [55]: mysys.D
Out[55]: NumPy array, format: long
[ 0.]

I get an error when I try to find the step response of this system.  I
think part of the problem is that the matrices aren't right.  I think
they should be

In [46]: A=array([[0,1],[0,0]])

In [47]: B=array([[0],[1]])

In [48]: C=array([[1,0]])

In [49]: D=array([[0]])

but for some reason I can't create a system with these matrices:

In [50]: mysys=scipy.signal.lti(A,B,C,D)
---------------------------------------------------------------------------
exceptions.TypeError                                 Traceback (most
recent call last)

/home/ryan/siue/mechatronics/system_modeling/<ipython console>

/usr/lib/python2.4/site-packages/scipy/signal/ltisys.py in
__init__(self, *args, **kwords)
223                                 self.__dict__['C'], \
224                                 self.__dict__['D'] =
abcd_normalize(*args)--> 225             self.__dict__['zeros'],
self.__dict__['poles'], \
226                                     self.__dict__['gain'] =
ss2zpk(*args)
227             self.__dict__['num'], self.__dict__['den'] = ss2tf(*args)

/usr/lib/python2.4/site-packages/scipy/signal/ltisys.py in ss2zpk(A,
B, C, D, input)
183       z, p, k -- zeros and poles in sequences and gain constant.
184     """
--> 185     return tf2zpk(*ss2tf(A,B,C,D,input=input))
186
187 class lti:

/usr/lib/python2.4/site-packages/scipy/signal/ltisys.py in ss2tf(A, B,
C, D, input)
154     for k in range(nout):
155         Ck = atleast_2d(C[k,:])
--> 156         num[k] = poly(A - dot(B,Ck)) + (D[k]-1)*den
157
158     return num, den

TypeError: array cannot be safely cast to required type

What am I doing wrong?

Thanks,

Ryan
```