%Illustration of Ziegler-Nichols frequency response method
%   kja 070425
aminit;
w=0:0.01:200;s=i*w;
P=exp(-s)./(s+1);
[xxx,iii]=min(abs(angle(P(1:300))+pi));
k=1;
%k=1/abs(P(iii));

figure(1); clf; subplot(221);
ampolezero(tf([1], [1]), [-1.1 1.3 -1.1 1.3]); hold on;

% Plot the positive part of the frequency curve
plot(real(k*P), imag(k*P), 'Linewidth', AM_data_linewidth);

% Annotate the plot
plot(real(k*P(iii)), imag(k*P(iii)), 'ro', 'MarkerSize', AM_data_markersize);
amtext(-1.05, 0.15, 'w = wa');

plot([0 0 0 0], [-1 -0.5 0.5 1], 'k+', 'LineWidth', AM_tick_linewidth);
plot([-1 -0.5 0.5 1], [0 0 0 0], 'k+', 'LineWidth', AM_tick_linewidth);
% amtext(-1, 0.2, '-1');
% amtext(-0.6, 0.2, '-0.5');
% amtext(0.45, 0.2, '0.5');
% amtext(1, 0.2, '1');

axis square
amprint('znfreq.eps');
