% EE 262
% Randy Dimmett -- NOTE: based on a script of Dr. Erickson's
%
% C(s) Script with PO lines
num = [1 a];
den = [ 1 4 0];
den = conv( [ 1 b], den);
rlocus(num,den)
grid on
title('EE 262 -- Randy Dimmett');

%  C(s)=K*(s+a)/(s+b) where a and b are user specified

hold on
len=10;
zeta = [0.707 0.6 0.5]; % for the 5%, 10% and 15% PO lines
for j = 1:3,
  theta = 3.14 - acos( zeta(j) );,
  xa=[0 len*cos(theta)]; ya=[0 len*sin(theta)];,
  plot(xa, ya, 'g');
end;

zoom on ; pause
zoom off

[x,y] = ginput(1)
pt=x+i*y;
k=-polyval(den,pt)/polyval(num,pt)

hold off


% For our case, k = 56.2470 - 0.0171i which implies k is about 56.25