python/dscr.py
changeset 0 0efde00f9229
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/dscr.py	Fri May 27 14:24:59 2011 +0530
@@ -0,0 +1,15 @@
+import scipy as sp
+from scipy import linalg
+from scipy import signal
+
+def dscr(H,Ts):
+    """ Given a Continuous system and a Time step, returns a discretized system."""
+    (n,m) = H.B.shape
+    S = sp.zeros((n+m,n+m))
+    S[:n,:n] = H.A
+    S[:n,n:] = H.B
+    s = linalg.expm(S*Ts)
+    f = s[:n,:n]
+    g = s[:n,n:]
+    Hd = signal.lti(f, g, H.C, H.D)
+    return Hd