# ctrbf

Calculates the controllability staircase form.

## Syntax

[ABAR, BBAR, CBAR, T, K] = ctrbf(A, B, C)

[ABAR, BBAR, CBAR, T, K] = ctrbf(A, B, C, TOL)

## Inputs

A
The state matrix (n x n), where n is the number of states.
B
The input matrix (n x p), where p is the number of inputs.
C
The output matrix (q x n), where q is the number of outputs.
TOL
The tolerance scalar. Default = size(A,1)*norm(A,1)*eps().

## Outputs

ABAR
The controllability staircase state matrix.
BBAR
The controllability staircase input matrix.
CBAR
The controllability staircase output matrix.
T
The similarity transform matrix.
K
A vector containing the number of controllable states factored from the transformation matrix.

## Examples

Matrices as input:
A = [10 5; 9 -20];
B = [3 -10; 10 -2];
C = [25 0; 0 15];
[Abar, Bbar, Cbar, T, k] = ctrbf(A, B, C);
Abar = [Matrix] 2 x 2
10    5
9  -20
Bbar = [Matrix] 2 x 2
3  -10
10   -2
Cbar = [Matrix] 2 x 2
25   0
0  15
T = [Matrix] 2 x 2
1  0
0  1
k = [Matrix] 1 x 2
2  0
%The decomposed system Abar shows an uncontrollable mode located at -20 and controllable modes at 10, 5 and 9.
Inputs from the state-space model:
sys_tf=tf([1],[1 5 6 0]);
sys=ss(sys_tf);
[Abar, Bbar, Cbar, T, k] = ctrbf(sys.a, sys.b, sys.c)
Abar = [Matrix] 3 x 3
0  1   0
0  0  -2
0  3  -5
Bbar = [Matrix] 3 x 1
0.00000
0.00000
0.50000
Cbar = [Matrix] 1 x 3
-1  0  0
T = [Matrix] 3 x 3
0   0  -1
0  -1   0
1   0   0
k = [Matrix] 1 x 3
1  1  1
%The decomposed system Abar shows an uncontrollable modes located at -2 and -5 and controllable modes at 1 and 3.