% Fig. 6.41   Feedback Control of Dynamic Systems, 8e 
%             Franklin, Powell, Emami
%

clear all;
%close all;
clf
 
num = 85*conv([1 1],[1 2 43.25]);
p = conv([1 2 82],[1 2 101]);
den = conv([1 0 0],p);

w=logspace(-1,2,1000);

[mag,phas] = bode(num,den,w);

[re,im] = nyquist(num,den,w);

ii=200:1000;

plot(re(ii),im(ii),'LineWidth',2);

xlabel('Real');
ylabel('Imaginary');
grid on
axis([-1.2 1.2 -1.2 1.2])
axis('square')
hold on;

%axis([-1.2 0.5 -1.2 0.5])


% add circle at mag = 1
w2=0:.05:2*pi;
x=cos(w2);
y=sin(w2);

plot(x,y,'r--','LineWidth',2)

title('Nyquist plot of the complex system in Ex 6.13.');
hold off;

