% Problem 5.16

num=[1 1];
den=[1 2 1];

%State space model
[A,B,C,D]=tf2ss(num,den)

% Controllability matrix
Co=ctrb(A,B)
r_Co=rank(Co)
if r_Co < size(A,1)
  disp('System is not controllable!')
else
  disp('System is controllable!')
end

% Observability matrix
Ob=obsv(A,C)
r_Ob=rank(r_Ob)
if r_Ob < size(A,1)
  disp('System is not observable!')
else
  disp('System is observable!')
end