% Script for problem 2.4
num=[2 0 1 -3 1 4];
den=[5 2 -1 -3 5 2 -4 2 -1];
disp('Solution to Problem 2.4')

% Solution of 2.4(a)
disp(' ')
disp('2.4(a) - using the function roots')
disp('---------------------------------')
disp(' ')
disp('Zeros:')
z=roots(num)
disp('Poles:')
p=roots(den)

disp(' ')
disp('2.4(a) - using the function tf2zp')
disp('---------------------------------')
disp(' ')
[z,p,k]=tf2zp(num,den)

% Solution of 2.4(b)
disp('Press ENTER to see solution 2.4(b)')
pause 
disp(' ')
disp('2.4(b)')
disp('------')
disp(' ')
[k,p,r]=residue(num,den);
disp('Fraction expansion coeficients')
k
disp('Poles of the system')
p
disp('Residue')
r

% Solution of 2.4(c)
disp('Press ENTER to see solution 2.4(c)')
pause 
disp(' ')
disp('2.4(c)')
disp('------')
disp(' ')
[ncl,dcl]=feedback(num,den,[1],[1],-1);
printsys(ncl,dcl,'s')
p=roots(dcl);
disp('Closed-loop poles')
p