# ctrb

Controllability of state-space model

## Syntax

``Co = ctrb(A,B)``
``Co = ctrb(sys)``

## Description

A dynamic system is said to be controllable if it is possible to apply control signals that drive the system to any state within a finite amount of time. This characteristic is also called reachability. `ctrb` computes a controllability matrix from state matrices or from a state-space model. You can use this matrix to determine controllability.

For instance, consider a continuous-time state-space model with `Nx` states, `Ny` outputs, and `Nu` inputs:

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

Here, `x`, `u` and `y` represent the states, inputs and outputs respectively, while `A`, `B`, `C` and `D` are the state-space matrices with the following sizes:

• `A` is an `Nx`-by-`Nx` real-valued or complex-valued matrix.

• `B` is an `Nx`-by-`Nu` real-valued or complex-valued matrix.

• `C` is an `Ny`-by-`Nx` real-valued or complex-valued matrix.

• `D` is an `Ny`-by-`Nu` real-valued or complex-valued matrix.

The system is controllable if the controllability matrix generated by `ctrb` $Co=\left[\begin{array}{ccccc}B& AB& {A}^{2}B& \dots & {A}^{n-1}B\end{array}\right]$ has full rank, that is, the rank is equal to the number of states in the state-space model. The controllability matrix `Co` has `Nx` rows and `Nxu` columns. For an example, see Controllability of SISO State-Space Model.

example

````Co = ctrb(A,B)` returns the controllability matrix `Co` using the state matrix `A` and input-to-state matrix `B`. The system is controllable if `Co` has full rank, that is, the rank of `Co` is equal to the number of states.```

example

````Co = ctrb(sys)` returns the controllability matrix of the state space model `sys`. This syntax is equivalent to:Co = ctrb(sys.A,sys.B);```

## Examples

collapse all

Define `A` and `B` matrices.

```A = [1 1; 4 -2]; B = [1 -1; 1 -1];```

Compute controllability matrix.

`Co = ctrb(A,B);`

Determine the number of uncontrollable states.

`unco = length(A) - rank(Co)`
```unco = 1 ```

The uncontrollable state indicates that `Co` does not have full rank 2. Therefore the system is not controllable.

For this example, consider the following SISO state-space model with 2 states:

`$A=\left[\begin{array}{cc}-1.5& -2\\ 1& 0\end{array}\right]\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}B=\left[\begin{array}{c}0.5\\ 0\end{array}\right]\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}C=\left[\begin{array}{cc}0& 1\end{array}\right]\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}D=1$`

Create the SISO state-space model defined by the following state-space matrices:

```A = [-1.5,-2;1,0]; B = [0.5;0]; C = [0,1]; D = 1; sys = ss(A,B,C,D);```

Compute the controllability matrix and find the rank.

`Co = ctrb(sys)`
```Co = 2×2 0.5000 -0.7500 0 0.5000 ```

The size of the controllability matrix depends on the size of the `A` and `B` matrices. For instance, if matrix A is an `Nx`-by-`Nx` matrix and matrix B is an `Nx`-by-`Nu` matrix, then the resultant matrix `Co` has `Nx` rows and `Nxu` columns. Here, `Nx` is the number of states and `Nu` is the number of inputs.

`rank(Co)`
```ans = 2 ```

Since the rank of the controllability matrix `Co` is equal to the number of states, the system `sys` is controllable.

Alternatively, you can also use just the `A` and `B` matrices to find the controllability matrix.

```Co = ctrb(sys.A,sys.B); rank(Co)```
```ans = 2 ```

## Input Arguments

collapse all

State matrix, specified as an `Nx`-by-`Nx` matrix where, `Nx` is the number of states.

Input-to-state matrix, specified as an `Nx`-by-`Nu` matrix where `Nx` is the number of states and `Nu` is the number of inputs.

State-space model or model array, specified as:

• A state-space (`ss`) model object, when the inputs `A`, `B`, `C` and `D` are numeric matrices or when converting from another model object type.

• A generalized state-space model (`genss`) object, when one or more of the matrices `A`, `B`, `C` and `D` includes tunable parameters, such as `realp` parameters or generalized matrices (`genmat`). The function uses the current values for tunable parameters.

• An uncertain state-space model (`uss`) object, when one or more of the inputs `A`, `B`, `C` and `D` includes uncertain matrices. The function uses the nominal values for uncertain parameters. Using uncertain models requires Robust Control Toolbox™ software.

## Output Arguments

collapse all

Controllability matrix, returned as an array. When `sys` is:

• A single state-space model with `Nx` states and `Nu` inputs, then the resultant array `Co` has `Nx` rows and `Nxu` columns.

• An array of state-space models `sys(:,:,j1,...,jN)`, then `Co` is an array with `N+2` dimensions, that is, `Co(:,:,j1,...,jN)`.

## References

[1] Paige, C. C. "Properties of Numerical Algorithms Related to Computing Controllability." IEEE Transactions on Automatic Control. Vol. 26, Number 1, 1981, pp. 130-138.

## Version History

Introduced before R2006a