# Control Theory

`abcddim (a, b, c, d)`
Check for compatibility of the dimensions of the matrices defining the linear system [A, B, C, D] corresponding to or a similar discrete-time system. If the matrices are compatibly dimensioned, then `abcddim` returns n = number of system states, m = number of system inputs, and p = number of system outputs. Otherwise `abcddim` returns n = m = p = -1.
`are (a, b, c, opt)`
Returns the solution, x, of the algebraic Riccati equation
```a' x + x a - x b x + c = 0
```
for identically dimensioned square matrices a, b, c. If b (c) is not square, then the function attempts to use `b*b'` (`c'*c`) instead. Solution method: apply Laub's Schur method (IEEE Transactions on Automatic Control, 1979) to the appropriate Hamiltonian matrix. opt is an option passed to the eigenvalue balancing routine. Default is `"B"`.
`c2d (a, b, t)`
Converts the continuous time system described by: into a discrete time equivalent model via the matrix exponential assuming a zero-order hold on the input and sample time t.
`dare (a, b, c, r, opt)`
Returns 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. Solution method: 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). opt is an option passed to the eigenvalue balancing routine. The default is `"B"`.
`dgram (a, b)`
Returns the discrete controllability and observability gramian for the discrete time system described by `dgram (a, b)` returns the discrete controllability gramian and `dgram (a', c')` returns the observability gramian.
`dlqe (a, g, c, sigw, sigv [, z])`
Linear quadratic estimator (Kalman filter) design for the discrete time system 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 Returns: l is the observer gain, `(A - A L C)` is stable. m is the Ricatti equation solution. p is the estimate error covariance after the measurement update. e are the closed loop poles of `(A - A L C)`.
`dlqr (a, b, q, r [, z])`
Linear quadratic regulator design for the discrete time system 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
```
Returns: k is the state feedback gain, `(A - B K)` is stable. p is the solution of algebraic Riccati equation. e are the closed loop poles of (A - B K).
`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
```a x a' - x + b b' = 0
```
or
```a' x a - x + b' b = 0
```
whichever is appropriate. Uses Schur decomposition method as in Kitagawa, International Journal of Control (1977); column-by-column solution method as suggested in Hammarling, IMA Journal of Numerical Analysis, (1982).
`is_controllable (a, b, tol)`
If the pair (a, b) is controllable, then return value 1. Otherwise, returns a value of 0. tol is a roundoff parameter, set to `2*eps` if omitted. Currently just constructs the controllability matrix and checks rank. A better method is as follows (Boley and Golub, Systems and Control Letters, 1984): Controllability is determined by applying Arnoldi iteration with complete re-orthogonalization to obtain an orthogonal basis of the Krylov subspace
`is_observable (a, c, tol)`
Returns 1 if the pair `(a, c)` is observable. Otherwise, returns a value of 0.
`lqe (a, g, c, sigw, sigv, z)`
```[k, p, e] = lqe (a, g, c, sigw, sigv, z)
```
Linear quadratic estimator (Kalman filter) design for the continuous time system where w, v are zero-mean gaussian noise processes with respective intensities
```sigw = cov (w, w)
sigv = cov (v, v)
```
z (if specified) is the cross-covariance `cov (w, v)`; the default value is `cov (w, v) = 0`. Observer structure is `dz/dt = A z + B u + k (y - C z - D u)` returns: k is observer gain: `(A - K C)` is stable. p is solution of algebraic Riccati equation. e is the vector of closed loop poles of `(A - K C)`.
`lqr (a, b, q, r, z)`
`[k, p, e] = lqr (a, b, q, r, z)`
Linear quadratic regulator design for the continuous time system to minimize the cost functional z omitted or z included Returns: k is state feedback gain: `(A - B K)` is stable. p is the stabilizing solution of appropriate algebraic Riccati equation. e is the vector of the closed loop poles of `(A - B K)`.
`lyap (a, b, c)`
Solve the Lyapunov (or Sylvester) equation via the Bartels-Stewart algorithm (Communications of the ACM, 1972). If `(a, b, c)` are specified, then `lyap` returns the solution of the Sylvester equation
```a x + x b + c = 0
```
If only `(a, b)` are specified, then `lyap` returns the solution of the Lyapunov equation
```a' x + x a + b = 0
```
If b is not square, then `lyap` returns the solution of either
```a' x + x a + b' b = 0
```
or
```a x + x a' + b b' = 0
```
whichever is appropriate. Solves by using the Bartels-Stewart algorithm (1972).
`tzero (a, b, c, d, bal)`
Compute the transmission zeros of [A, B, C, D]. bal = balancing option (see balance); default is `"B"`. Needs to incorporate `mvzero` algorithm to isolate finite zeros; see Hodel, Computation of System Zeros with Balancing, Linear Algebra and its Applications, July 1993.