# xelim

Eliminate states from state-space models

Since R2023b

## Syntax

``rsys = xelim(sys,elim)``
``rsys = xelim(sys,elim,method)``

## Description

````rsys = xelim(sys,elim)` simplifies the state-space model `sys` by eliminating the states specified 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 eliminated.This function is useful to eliminate states known to settle quickly (fast modes) or contribute little to the input/output map. When you don’t know which states to eliminate, use `reducespec` and the model-order reduction workflow.```

example

````rsys = xelim(sys,elim,method)` also specifies the elimination method. Set `method` to either `"MatchDC"` or `"Truncate"`.```

## Examples

collapse all

Consider the following continuous fourth-order model.

`$h\left(s\right)=\frac{{s}^{3}+11{s}^{2}+36s+26}{{s}^{4}+14.6{s}^{3}+74.96{s}^{2}+153.7s+99.65}.$`

To reduce its order, first compute a balanced state-space realization with `balreal`.

```h = tf([1 11 36 26],[1 14.6 74.96 153.7 99.65]); [hb,g] = balreal(h);```

Examine the Gramians.

`g'`
```ans = 1×4 0.1394 0.0095 0.0006 0.0000 ```

The last three diagonal entries of the balanced Gramians are relatively small. Eliminate these three least-contributing states with `xelim`, using both matched DC gain and direct-deletion methods.

```hmdc = xelim(hb,2:4,"MatchDC"); hdel = xelim(hb,2:4,"Truncate");```

Both `hmdc` and `hdel` are first-order models. Compare their Bode responses against that of the original model.

```op = bodeoptions; op.PhaseMatching = "on"; bodeplot(h,hmdc,'r--',hdel,'k-.',op) legend("Original","State elimination (match DC)",... "State elimination (truncate)")``` The reduced-order model `hdel` is clearly a better frequency-domain approximation of `h`. Now compare the step responses.

```stepplot(h,hmdc,'r--',hdel,'k-.') legend("Original","State elimination (match DC)",... "State elimination (truncate)",Location="southeast")``` While `hdel` accurately reflects the transient behavior, only `hmdc` gives the true steady-state response.

For faster and more accurate results, use `reducespec` for model reduction workflows.

## Input Arguments

collapse all

Dynamic system model, specified as an ordinary or sparse LTI model.

The input model must have a valid state-space representation, such as `tf`, `ss`, `sparss`, `mechss` models. For generalized or uncertain state-space models (`genss`, `uss`), the function uses the current value of the model. For identified models (`idss`), the function uses the identified value.

State elimination vector, specified as one of these.

• A vector containing index values of states you want to discard.

• A vector of logical values of the same size as the number of states, where the `true` (`1`) values specifies the states you want to discard.

State elimination method, specified as `"MatchDC"` or `"Truncate"`. This argument specifies how the function eliminates the states with weak contribution.

• `"MatchDC"` — Enforce matching DC gains. To do so, the algorithm treats x2 as infinitely fast and sets its derivative to zero. The resulting algebraic equation is used to express x2 in terms of x1 and eliminate it. For details, see Algorithms

• `"Truncate"` — Simply drop x2, and use x1 as reduced state.

The `"Truncate"` option tends to produce a better approximation in the frequency domain, but the DC gains are not guaranteed to match.

## Output Arguments

collapse all

Reduced-order model, returned as a state-space model.

## Algorithms

collapse all

For a state-space model

`$\begin{array}{l}\stackrel{˙}{x}=Ax+Bu\\ y=Cx+Du\end{array}$`

the function partitions the state vector into x1 (to keep) and x2 (to eliminate).

`$\begin{array}{l}\left[\begin{array}{c}{\stackrel{˙}{x}}_{1}\\ {\stackrel{˙}{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}$`

### `"MatchDC"` Method

For continuous-time models, this method sets the derivative of x2 to zero and solves the resulting equation for x1. The reduced-order model is given by

`$\begin{array}{l}{\stackrel{˙}{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}$`

Similarly, for discrete-time models, the algorithm sets ${x}_{2}\left[n+1\right]={x}_{2}\left[n\right]$ to recompute the matrices.

`xelim` returns a scaled version of this realization. To disable this scaling, set `sys.Scaled` to `true` before eliminating the states.

### `"Truncate"` Method

For this method, the algorithm simply drops x2, and uses x1 as reduced state. The reduced-order model is given by

`$\begin{array}{l}{\stackrel{˙}{x}}_{1}={A}_{11}{x}_{1}+{B}_{1}u\\ y={C}_{1}{x}_{1}\end{array}$`

`xelim` returns a scaled version of this realization. To disable this scaling, set `sys.Scaled` to `true` before eliminating the states.

## Version History

Introduced in R2023b