% Problem 5.22
disp('System model:')
A=[0  1        0   0      0    0;
   0  0        1   0      0    0;
   0  0        0   1      0    0; 
   0  0        0   0      1    0;
   0  0        0   0      0    1;
   0 -8.11 -12131 -97.8 -463   -0.996]
B=[0; 0; 0; 0; 0; 1]
C=[19080 90.6 -576 -0.331 1.65 0]

disp('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

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

disp('Transfer function:')
D=0;
[num,den]=ss2tf(A,B,C,D,1);
for i=1:length(num),
  if abs(num(i)) < 1.0e-015
     num(i)=0;
  end
end
printsys(num,den,'s')

disp('Zeros and poles:')
[z,p,k]=ss2zp(A,B,C,D,1)

disp('Minimal realization:')
[Nm,Dm]=minreal(num,den,1.e-15);
printsys(Nm,Dm,'s')