# balreal

Computes a Gramian balanced realization of an LTI model.

## Syntax

[sysR, G, T, TI] = balreal(SYS)

## Inputs

SYS
A state-space or transfer function model.

## Outputs

sysR
A state-space or transfer function model.
G
The diagonal vector of the balanced Gramian matrix.
T
The state similarity transform matrix.
TI
The state similarity transform inverse matrix.

## Examples

Transfer function model as an input:
sys_tf = tf([1],[1 5 6]);
[sysR,g,T,Ti] = balreal(sys_tf)

sysR = object [
Scaled: 0
TimeUnit: seconds
ts: 0
a: [Matrix] 2 x 2
-0.71429 -1.71429
1.71429 -4.28571
b: [Matrix] 2 x 1
0.37796
-0.37796
c: [Matrix] 1 x 2
0.37796 0.37796
d: 0
e: [Matrix] 0 x 0
type: StateSpaceModel
]
g = [Matrix] 2 x 1
0.10000
0.01667
T = [Matrix] 2 x 2
0.75593 2.26779
-0.75593 0.37796
Ti = [Matrix] 2 x 2
0.18898 -1.13389
0.37796 0.37796
State-space model as an input:

A = [-10     0     0     0     0;
0    -2     0     0     0;
0     0    -30     0     0;
0     0     0    -4     0;
0     0     0     0    -50];

B = [9.593    8.407;
5.472    2.543;
1.386    8.143;
1.493    2.435;
2.575    9.293];

C = [1.3500    1.1966    1.2511    1.6160    1.4733];

D = [0 1];

Sys1 = ss(A, B, C, D);
[SysR, g, T, Ti] = balreal(Sys1)
SysR = object [
Scaled: 0
TimeUnit: seconds
ts: 0
a: [Matrix] 5 x 5
-5.39875 6.74403 -4.01886 -0.95050 -0.72669
5.68053 -17.45928 16.11510 4.30148 3.32031
-2.66244 14.84407 -28.32974 -11.94818 -9.90222
0.19712 1.03910 -4.54460 -5.80082 -9.03928
-0.72332 3.06315 -7.27610 1.72517 -39.01140
b: [Matrix] 5 x 2
4.04750 3.93894
-1.20829 -3.79737
-0.05853 2.13943
-0.41052 0.27913
0.24580 0.29025
c: [Matrix] 1 x 5
5.64778 -3.98496 2.14023 0.49643 0.38034
d:[Matrix] 1 x 2
0 1
e: [Matrix] 0 x 0
type: StateSpaceModel
]
g = [Matrix] 5 x 1
2.95415
0.45477
0.08084
0.02124
0.00185
T = [Matrix] 5 x 5
0.15729 0.33547 0.06320 0.32911 0.04816
-0.19161 0.23181 -0.16413 -0.01502 -0.15096
-0.12062 0.1142 0.15493 -0.22602 0.23154
-0.08874 -0.02920 -0.03644 0.32284 0.06564
0.00082 -0.01119 -0.19294 0.05476 0.18826
Ti = [Matrix] 5 x 5
1.48074 -1.67837 -1.56242 -2.88553 1.20318
1.65882 1.40707 0.75621 -1.12430 0.16593
0.32144 -1.17097 1.41542 1.14499 -3.16126
0.53952 -0.25587 -0.53864 2.23663 -0.46058
0.26459 -1.03468 1.65901 0.46858 2.21058