# balreal

Gramian-based input/output balancing of state-space realizations

## Syntax

`[`

* sysb*,

*] = balreal(*

`g`

*)*

`sys`

[

*,*

`sysb`

*,*

`g`

*,*

`T`

*] = balreal(*

`Ti`

*)*

`sys`

[___] = balreal(

*,*

`sys`

*)*

`opts`

## Description

`[`

computes a
balanced realization * sysb*,

*] = balreal(*

`g`

*)*

`sys`

`sysb`

for the stable portion
of the LTI model `sys`

. `balreal`

handles
both continuous and discrete systems. If `sys`

is
not a state-space model, it is first and automatically converted to
state space using `ss`

.For stable systems, `sysb`

is an equivalent
realization for which the controllability and observability Gramians
are equal and diagonal, their diagonal entries forming the vector `g`

of
Hankel singular values. Small entries in `g`

indicate
states that can be removed to simplify the model (use `modred`

to reduce the model order).

If `sys`

has unstable poles, its stable part
is isolated, balanced, and added back to its unstable part to form `sysb`

.
The entries of `g`

corresponding to unstable modes
are set to `Inf`

.

`[`

also
returns the vector * sysb*,

*,*

`g`

*,*

`T`

*] = balreal(*

`Ti`

*)*

`sys`

`g`

containing the diagonal of
the balanced Gramian, the state similarity transformation *x*=

_{b}*Tx*used to convert

`sys`

to `sysb`

, and
the inverse transformation *Ti*=

*T*.

^{-1}If the system is normalized properly, the diagonal `g`

of
the joint Gramian can be used to reduce the model order. Because `g`

reflects
the combined controllability and observability of individual states
of the balanced model, you can delete those states with a small `g(i)`

while
retaining the most important input-output characteristics of the original
system. Use `modred`

to perform
the state elimination.

`[___] = balreal(`

computes the balanced realization using options that you specify using * sys*,

*)*

`opts`

`balredOptions`

. Options include offset and tolerance options for
computing the stable-unstable decompositions. The options also allow you to limit the
Gramian computation to particular time and frequency intervals. See `balredOptions`

for details. ## Examples

## Algorithms

Consider the model

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

with controllability and observability Gramians *W _{c}* and

*W*. The state coordinate transformation $$\overline{x}=Tx$$ produces the equivalent model

_{o}$$\begin{array}{l}\dot{\overline{x}}=TA{T}^{-1}\overline{x}+TBu\\ y=C{T}^{-1}\overline{x}+Du\end{array}$$

and transforms the Gramians to

$$\begin{array}{cc}{\overline{W}}_{c}=T{W}_{c}{T}^{T},& {\overline{W}}_{o}={T}^{-T}{W}_{o}\end{array}{T}^{-1}$$

The function `balreal`

computes a particular
similarity transformation *T* such that

$${\overline{W}}_{c}={\overline{W}}_{o}=diag(g)$$

See [1], [2] for details on the algorithm.

If you use the `TimeIntervals`

or `FreqIntervals`

options of
`balredOptions`

, then
`balreal`

bases the balanced realization on time-limited or
frequency-limited controllability and observability Gramians. For information about
calculating time-limited and frequency-limited Gramians, see `gram`

and [4].

## References

[1] Laub, A.J., M.T. Heath, C.C. Paige, and
R.C. Ward, "Computation of System Balancing Transformations and Other
Applications of Simultaneous Diagonalization Algorithms," *IEEE ^{®} Trans.
Automatic Control*, AC-32 (1987), pp. 115-122.

[2] Moore, B., "Principal Component Analysis
in Linear Systems: Controllability, Observability, and Model Reduction," *IEEE Transactions
on Automatic Control*, AC-26 (1981), pp. 17-31.

[3] Laub, A.J., "Computation of Balancing Transformations," *Proc.
ACC*, San Francisco, Vol.1, paper FA8-E, 1980.

[4] Gawronski, W. and J.N. Juang. “Model
Reduction in Limited Time and Frequency Intervals.” *International
Journal of Systems Science*. Vol. 21, Number 2, 1990, pp.
349–376.

## See Also

`balred`

| `balredOptions`

| `gram`

| `modred`

**Introduced before R2006a**