vibudh is talking

Posts tagged ‘observability’

Control System: State Space using MATLAB

For a system defined by its state space variables, it is possible to determine the controllability, observability and hence the stability of the system using MATLAB. We will be discuss the same here with the help of an example.

A system is said to be controllable if we can transform the state of a system from xo to x(t) with the help of a control function u(t) over a finite period of time. If from measurements of output y(t) taken over a finite period of time, state of  a system x(t) can be determined, then the system is observable.

If a system is both controllable and observable then we can say that the system is stable.

Consider a linear time invariant(LTI) system described by the state equations:

x = A x + B u

y = C x + D u

Here x, y are the state variables, u represents the unit step response and A, B, C, D are the constants which depend on the system.

For a model with Nx states, Ny outputs, and Nu inputs:

  • a is an Nx-by-Nx real- or complex-valued matrix.
  • b is an Nx-by-Nu real- or complex-valued matrix.
  • c is an Ny-by-Nx real- or complex-valued matrix.
  • d is an Ny-by-Nu real- or complex-valued matrix.

sys = ss(a,b,c,d,Tscreates the discrete-time model

with sample time Ts (in seconds). Set Ts = -1 or Ts = [] to leave the sample time unspecified.

Matlab Code:-

a=[0 1 0; 0 0 1; -6 -11 -6];

b=[0; 0; 2];

c=[1 0 0];


sys = ss(a,b,c,d);                                %Creating the state space model

xo=[0 0 0];                                           %Setting initial conditions


step(sys);                                               %for step response

ob = obsv(sys);                                   %for calculating observability

unob = length(a)-rank(ob)             %for calculating unobservability

ct = ctrb(sys);                                      %for calculating controllability

unct = length(a)-rank(ct)                %for calculating uncontrollability

eigen = eig(a)                                        %for obtaining the eigen values


unob = 0

unct =0

eigen = -1.0000



As the system is controllable and observable, hence we can say that the system is stable.