# modred

Eliminate states from state-space models

## Syntax

`rsys = modred(sys,elim)`

rsys = modred(sys,elim,'method')

## Description

reduces the order of a continuous or discrete state-space model `rsys`

= modred(`sys`

,elim)`sys`

by eliminating the states found in the vector `elim`

. The full state
vector *X* is partitioned as *X* =
[*X1*;*X2*] where *X1* is the
reduced state vector and *X2* is discarded.

`elim`

can be a vector of indices or a logical vector commensurate
with *X* where true values mark states to be discarded. This function
is usually used in conjunction with `balreal`

. Use
`balreal`

to first isolate states with negligible contribution to
the I/O response. If `sys`

has been balanced with
`balreal`

and the vector `g`

of Hankel singular
values has M small entries, you can use `modred`

to eliminate the
corresponding M states. For example:

[sys,g] = balreal(sys) % Compute balanced realization elim = (g<1e-8) % Small entries of g are negligible states rsys = modred(sys,elim) % Remove negligible states

`rsys = modred(sys,elim,'method')`

also specifies the state
elimination method. Choices for `'method'`

include

`'MatchDC'`

(default): Enforce matching DC gains. The state-space matrices are recomputed as described in Algorithms.`'Truncate'`

: Simply delete*X2*.

The `'Truncate'`

option tends to produces a better approximation in
the frequency domain, but the DC gains are not guaranteed to match.

If the state-space model `sys`

has been balanced with
`balreal`

and the grammians have *m* small
diagonal entries, you can reduce the model order by eliminating the last
*m* states with `modred`

.

## Examples

## Algorithms

The algorithm for the matched DC gain method is as follows. For continuous-time models

$$\begin{array}{l}\dot{x}=Ax+By\\ y=Cx+Du\end{array}$$

the state vector is partitioned into *x _{1}*, to
be kept, and

*x*, to be eliminated.

_{2}$$\begin{array}{l}\left[\begin{array}{c}{\dot{x}}_{1}\\ {\dot{x}}_{2}\end{array}\right]=\left[\begin{array}{cc}{A}_{11}& {A}_{12}\\ {A}_{21}& {A}_{22}\end{array}\right]\left[\begin{array}{c}{x}_{1}\\ {x}_{2}\end{array}\right]+\left[\begin{array}{c}{B}_{1}\\ {B}_{2}\end{array}\right]u\\ y=\left[\begin{array}{cc}{C}_{1}& {C}_{2}\end{array}\right]x+Du\end{array}$$

Next, the derivative of *x _{2}* is set to zero
and the resulting equation is solved for

*x*. The reduced-order model is given by

_{1}$$\begin{array}{l}{\dot{x}}_{1}=\left[{A}_{11}-{A}_{12}{A}_{22}{}^{-1}{A}_{21}\right]{x}_{1}+\left[{B}_{1}-{A}_{12}{A}_{22}{}^{-1}{B}_{2}\right]u\\ y=\left[{C}_{1}-{C}_{2}{A}_{22}{}^{-1}{A}_{21}\right]x+\left[D-{C}_{2}{A}_{22}{}^{-1}{B}_{2}\right]u\end{array}$$

The discrete-time case is treated similarly by setting

$${x}_{2}[n+1]={x}_{2}[n]$$

**Introduced before R2006a**