% Problem 6.10
disp('Problem 6.10')
disp(' ')
disp('State-space model:')

A=[ -0.01357   -32.2 -46.300  0
     0.00012    0.0    1.214  0
    -0.0001212  0.0   -1.214  1
     0.00057    0.0   -9.100 -0.6696]
B=[-0.433; 0.1394; -0.1394; -0.1577]
C=[0 0 0 1
   1 0 0 0]
D=[0; 0]

% Transfer functions
disp('Open-loop transfer function:')
[num,den]=ss2tf(A,B,C,D,1);
printsys(num,den)

% Closed-loop transfer functions
disp(' ')
disp('Closed-loop No. 11:')
[n1c,d1c]=cloop(num(1,:),den,-1);
printsys(n1c,d1c)

disp(' ')
disp('Closed-loop No. 21:')
[n2c,d2c]=cloop(num(2,:),den,-1);
printsys(n2c,d2c)
% Steady state errors
disp(' ')

disp('Steady state errors:')
Kp1ss=num(1,length(num))/den(1,length(den));
Kp2ss=num(2,length(num))/den(1,length(den));
e1ss=1/(1+Kp1ss)
e2ss=1/(1+Kp2ss)

