aminit;

%Design of PI controller by Loop shaping
K=[];TI=[];PHM=[];WGC=[];P='1./(s+1).^4';str='b-.';
for wgc=0.1:0.1:0.5,
s=i*wgc;pgc=eval(P);
Ti=0.5/wgc;k=wgc*Ti/sqrt(1+wgc^2*Ti^2)/abs(pgc);K=[K,k];TI=[TI,Ti];
C='k.*(1+1./(s*Ti))';
w=logspace(-2,1,100);s=i*w;one=ones(size(w));
pv=eval(P);cv=eval(C);L=pv.*cv;
[xx,kk]=min(abs(abs(L)-1));WGC=[WGC,xx];
phm=180+180*angle(L(kk))/pi;PHM=[PHM,phm];
%Nyquist plot
subplot(2,2,1)
pl=plot(real(L),imag(L),str);hold on
set(pl,'Linewidth', AM_bode_linewidth);
axis([-1.5 0.5 -1.5 0.5]);axis square;
str='b-';
end
xx=-1.5:0.1:0.5;null=zeros(size(xx));
plot(xx,null,'b-',null,xx,'b-');
fi=5*pi/6:0.01:10*pi/6;
plot(cos(fi),sin(fi));

amprint('procctrl-pinyq.eps');
