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

clear all;
close all;
clf
 
w=logspace(-2,3,100);

num = 1;
den = conv([1 0],[1 2 1]);

figure(1)
rlocus( tf(num, den ) )

set(findall(gcf,'type','line'),'linewidth',3);

%grid
 
figure(2)
bode( num, den )

set(findall(gcf,'type','line'),'linewidth',3);

grid

figure(3)

[re,im] = nyquist(0.5*num,den,w);
plot(re,im,re,-im,'LineWidth',1);


axis([-4 1 -1 1]);
%axis([-10 5 -2 2]);
axis('square')
xlabel('Re(G(s))');
ylabel('Im(G(s))');
title('Inner portion of Nyquist plot');
grid on;
hold on

ii=[11 21 47 61];

plot(re(ii),im(ii),'*');
plot(-1,0,'*', 'MarkerSize', 12)

figure(4)


[re,im] = nyquist(1*num,den,w);
plot(re,im,re,-im,'LineWidth',2);



axis([-4 1 -1 1]);
%axis([-10 5 -2 2]);
axis('square')
xlabel('Re(G(s))');
ylabel('Im(G(s))');
title('Inner portion of Nyquist plot');
grid on;
hold on

ii=[11 21 47 61];

plot(re(ii),im(ii),'*');
plot(-1,0,'*', 'MarkerSize', 12)


figure(5)


[re,im] = nyquist(2*num,den,w);
plot(re,im,re,-im,'LineWidth',3);


axis([-4 1 -1 1]);
%axis([-10 5 -2 2]);
axis('square')
xlabel('Re(G(s))');
ylabel('Im(G(s))');
title('Inner portion of Nyquist plot');
grid on;
hold on

ii=[11 21 47 61];

plot(re(ii),im(ii),'*');
plot(-1,0,'*', 'MarkerSize', 12)



figure(6)


[re,im] = nyquist(5*num,den,w);
plot(re,im,re,-im,'LineWidth',4);


axis([-4 1 -1 1]);
%axis([-10 5 -2 2]);
axis('square')
xlabel('Re(G(s))');
ylabel('Im(G(s))');
title('Inner portion of Nyquist plot');
grid on;
hold on

ii=[11 21 47 61];

plot(re(ii),im(ii),'*');
plot(-1,0,'*', 'MarkerSize', 12)



figure(7)

[re,im] = nyquist(0.5*num,den,w);
plot(re,im,re,-im,'LineWidth',1);

hold on;

[re,im] = nyquist(1*num,den,w);
plot(re,im,re,-im,'LineWidth',2);

[re,im] = nyquist(2*num,den,w);
plot(re,im,re,-im,'LineWidth',3);

[re,im] = nyquist(5*num,den,w);
plot(re,im,re,-im,'LineWidth',4);

axis([-4 1 -1 1]);
%axis([-5 2 -1 1]);
axis('square')
xlabel('Re(G(s))');
ylabel('Im(G(s))');
title('Inner portion of Nyquist plot');
grid on;
hold on

ii=[11 21 47 61];

plot(re(ii),im(ii),'*');
plot(-1,0,'*', 'MarkerSize', 12)




hold off
