close all;
clear all;
L5 = tf(1.5,[1 2 0])*tf([1 0.5],[1 0.1])*tf([1 1],[1 0.2]);

w = logspace(log10(0.28),2,1000);
[s_r,s_i] = nyquist(L5,w);


s_r = s_r(:);
s_i = s_i(:);
s_sn = s_r+s_i*i;
s_sp = s_r-s_i*i;

x = (s_r(1):0.1:0);

a = 5;
b = 0.8;
d = asin(s_i(1)/b);
c = s_r(1)/cos(d);
t1 = -90:1:90;
t2 = (abs(d*180/pi):1:90);
t3 = -90:1:(d*180/pi);

y3 = a*cos(t1*pi/180) + j*b*sin(t1*pi/180);
y4 = c*cos(t2*pi/180) + j*b*sin(t2*pi/180);
y5 = c*cos(t3*pi/180) + j*b*sin(t3*pi/180);


figure(5);
plot(s_sn,'b-','linewidth',2);hold on;
plot(s_sp,'b--','linewidth',2);

plot(y3,'b-.','linewidth',2);
plot(y4,'b-.','linewidth',2);
plot(y5,'b-.','linewidth',2);



plot(-1,0,'r+','linewidth',2);
xlabel('Re','fontsize',16);
ylabel('Im','fontsize',16);
title('Nyquist Diagram','fontsize',16);
set(gca,'YTick',[-5 0 5]);
set(gca,'XTick',[-100 -1 0 100]);

axis([-16,7,-1,1]);


plot([b*j,s_sn(170),s_sp(5)],'b>','Linewidth',6);
plot([-b*j,s_sp(170),s_sn(5)],'b<','Linewidth',6);
grid;