python/myc2d.py
changeset 0 0efde00f9229
equal deleted inserted replaced
-1:000000000000 0:0efde00f9229
       
     1 #!/usr/bin/python
       
     2 
       
     3 from dscr import dscr
       
     4 import scipy as sp
       
     5 
       
     6 def myc2d(G,Ts):
       
     7     """ Produces numerator and denominator of discrete transfer 
       
     8     function in powers of z^{-1}
       
     9     G is continuous transfer function; time delays are not allowed
       
    10     Ts is the sampling time, all in consistent time units. """
       
    11     H = dscr(G,Ts)
       
    12     num1, den1 = H.num, H.den
       
    13     A = den1[::-1]
       
    14     num2 = num1[::-1]
       
    15     nonzero = sp.find(num1)
       
    16     B = num2(nonzero)
       
    17     k = len(den1) - len(num1)
       
    18     return B,A,k