% Solution of Problem 2.20
numc=1; denc=[1 1 0];
Ts=0.5;
[numd,dend]=c2dm(numc,denc,Ts,'zoh')

% Controller (Kp=1, Ki=1)
ncomp=[2 1]; dcomp=[1 -1];

% Cascade connection of Gd(z), Zoh element and G(s)
[n_op,d_op]=series(ncomp,dcomp,numd,dend);

% Closed-loop transfer function
[n_cl,d_cl]=feedback(n_op,d_op,1,1,-1);

disp(' ')
disp('2.20(a) - closed-loop transfer function')
disp('---------------------------------------')
printsys(n_cl,d_cl,'z')

disp(' ')
disp(' ')
disp('2.20(b) - closed-loop zeros and poles')
disp('-------------------------------------')
[z,p,k]=tf2zp(n_cl,d_cl);
disp(' ')
disp('Zeros:')
z
disp(' ')
disp('Poles:')
p

% Unit step response
dstep(n_cl,d_cl,20)
grid
xlabel('k')
ylabel('y(k)')