Control Theory
**************

Most of the functions described in this chapter were contributed by A. Scottedward Hodel A.S.Hodel@eng.auburn.edu and R. Bruce Tenison Bruce.Tenison@eng.auburn.edu.  They have also written a larger collection of functions for solving linear control problems.  It is currently being updated for Octave version 2, with snapshots of the sources available from ftp://ftp.eng.auburn.edu/pub/hodel.

 -- Function File: [N, M, P] = abcddim (A, B, C, D)
     Check for compatibility of the dimensions of the matrices defining the linear system [A, B, C, D] corresponding to

          dx/dt = a x + b u
          y = c x + d u

     or a similar discrete-time system.

     If the matrices are compatibly dimensioned, then abcddim returns

     n
          The number of system states.

     m
          The number of system inputs.

     p
          The number of system outputs.

     Otherwise abcddim returns N = M = P = -1.

 -- Function File: are (A, B, C, OPT)

     Return the solution, X, of the algebraic Riccati equation

          a' * x + x * a - x * b * x + c = 0

     for identically dimensioned square matrices A, B, and C.  If B is not square, are attempts to use B*B' instead.  If C is not square, are attempts to use C'*C) instead.

     To form the solution, Laub's Schur method (IEEE Transactions on Automatic Control, 1979) is applied to the appropriate Hamiltonian matrix.

     The optional argument OPT is passed to the eigenvalue balancing routine.  If it is omitted, a value of "B" is assumed.

 -- Function File: c2d (A, B, T)
     Convert the continuous time system described by:

          dx/dt = a x + b u

     into a discrete time equivalent model

          x[k+1] = Ad x[k] + Bd u[k]

     via the matrix exponential assuming a zero-order hold on the input and sample time T.

 -- Function File: dare (A, B, C, R, OPT)

     Return the solution, X of the discrete-time algebraic Riccati equation

          a' x a - x + a' x b (r + b' x b)^(-1) b' x a + c = 0

     for matrices with dimensions:

     a
          N by N.

     b
          N by M.

     c
          N by N, symmetric positive semidefinite.

     r
          M by M, symmetric positive definite (invertible).

     If C is not square, then the function attempts to use C'*C instead.

     To form the solution, Laub's Schur method (IEEE Transactions on Automatic Control, 1979) is applied to the appropriate symplectic matrix.

     See also Ran and Rodman, Stable Hermitian Solutions of Discrete Algebraic Riccati Equations, Mathematics of Control, Signals and Systems, Volume 5, Number 2 (1992).

     The optional argument OPT is passed to the eigenvalue balancing routine.  If it is omitted, a value of "B" is assumed.

 -- Function File: dgram (A, B)
     Return the discrete controllability or observability gramian for the discrete time system described by

          x[k+1] = A x[k] + B u[k]
            y[k] = C x[k] + D u[k]

     For example, dgram (A, B) returns the discrete controllability gramian and dgram (A', C') returns the observability gramian.

 -- Function File: [L, M, P, E] = dlqe (A, G, C, SIGW, SIGV, Z)
     Construct the linear quadratic estimator (Kalman filter) for the discrete time system

          x[k+1] = A x[k] + B u[k] + G w[k]
            y[k] = C x[k] + D u[k] + w[k]

     where W, V are zero-mean gaussian noise processes with respective intensities SIGW = cov (W, W) and SIGV = cov (V, V).

     If specified, Z is cov (W, V).  Otherwise cov (W, V) = 0.

     The observer structure is

          z[k+1] = A z[k] + B u[k] + k(y[k] - C z[k] - D u[k])

     The following values are returned:

     l
          The observer gain, (A - ALC). is stable.

     m
          The Riccati equation solution.

     p
          The estimate error covariance after the measurement update.

     e
          The closed loop poles of (A - ALC).

 -- Function File: [K, P, E] = dlqr (A, B, Q, R, Z)
     Construct the linear quadratic regulator for the discrete time system

          x[k+1] = A x[k] + B u[k]

     to minimize the cost functional

          J = Sum (x' Q x + u' R u)

     Z omitted or

          J = Sum (x' Q x + u' R u + 2 x' Z u)

     Z included.

     The following values are returned:

     k
          The state feedback gain, (A - BK) is stable.

     p
          The solution of algebraic Riccati equation.

     e
          The closed loop poles of (A - BK).

 -- Function File: dlyap (A, B)
     Solve the discrete-time Lyapunov equation a x a' - x + b = 0 for square matrices A, B.  If B is not square, then the function attempts to solve either