Accelerating the pace of engineering and science

# balreal

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

## Syntax

[sysb, g] = balreal(sys)
[sysb, g] = balreal(sys,'AbsTol',ATOL,'RelTol',RTOL,'Offset',ALPHA)
[sysb, g] = balreal(sys, condmax)
[sysb, g, T, Ti] = balreal(sys)
[sysb, g] = balreal(sys, opts)

## Description

[sysb, g] = balreal(sys) computes a balanced realization 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.

[sysb, g] = balreal(sys,'AbsTol',ATOL,'RelTol',RTOL,'Offset',ALPHA) specifies additional options for the stable/unstable decomposition. See the stabsep reference page for more information about these options. The default values are ATOL = 0, RTOL = 1e-8, and ALPHA = 1e-8.

[sysb, g] = balreal(sys, condmax) controls the condition number of the stable/unstable decomposition. Increasing condmax helps separate close by stable and unstable modes at the expense of accuracy. By default condmax=1e8.

[sysb, g, T, Ti] = balreal(sys) also returns the vector g containing the diagonal of the balanced gramian, the state similarity transformation xb = 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.

[sysb, g] = balreal(sys, opts) computes the balanced realization using the options specified in the hsvdOptions object opts.

## Examples

### Balanced Realization of Stable System

Consider the following zero-pole-gain model, with near-canceling pole-zero pairs:

```sys = zpk([-10 -20.01],[-5 -9.9 -20.1],1)
```
```sys =

(s+10) (s+20.01)
----------------------
(s+5) (s+9.9) (s+20.1)

Continuous-time zero/pole/gain model.

```

A state-space realization with balanced gramians is obtained by

```[sysb,g] = balreal(sys);
```

The diagonal entries of the joint gramian are

```g'
```
```ans =

0.1006    0.0001    0.0000

```

This indicates that the last two states of sysb are weakly coupled to the input and output. You can then delete these states by

```sysr = modred(sysb,[2 3],'del');
```

This yields the following first-order approximation of the original system.

```zpk(sysr)
```
```ans =

1.0001
--------
(s+4.97)

Continuous-time zero/pole/gain model.

```

Compare the Bode responses of the original and reduced-order models.

```bodeplot(sys,sysr,'r--')
```

The plots shows that removing the second and third states does not have much effect on system dynamics.

### Balanced Realization of Unstable System

Create this unstable system:

```sys1=tf(1,[1 0 -1])

Transfer function:
1
-------
s^2 - 1
```

Apply balreal to create a balanced gramian realization.

```[sysb,g]=balreal(sys1)

a =
x1  x2
x1   1   0
x2   0  -1

b =
u1
x1  0.7071
x2  0.7071

c =
x1       x2
y1   0.7071  -0.7071

d =
u1
y1   0

Continuous-time model.

g =

Inf
0.2500
```

The unstable pole shows up as Inf in vector g.

expand all

### Algorithms

Consider the model

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

with controllability and observability gramians Wc and Wo. The state coordinate transformation $\overline{x}=Tx$ produces the equivalent model

$\begin{array}{l}\stackrel{˙}{\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\left(g\right)$

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

## 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.