aminit;					% initialize MATALB

%The six frequency responses for the basic loop
%PI Control of a process with 4 equal lags
P = tf(1,[1 4 6 4 1]); 
%Controller parameters
%k=0.77506;
%Ti=2.0511;
%ki=k/Ti;
k=0.75;
ki=0.35;
T=0.7;
%---------------------------------------------------
%Prels
dencl=[1 4 6 4 1+k ki];
numr=[k ki];
denp=[1 4 6 4 1];
denpr=[T^4 4*T^3 6*T^2 4*T 1];
%---------------------------------------------------
%The six systems
sys11=tf(numr,dencl);
sys12=tf([1 0],dencl);
sys21=tf(conv(numr,denp),dencl);
sys22=tf(conv([1 0],denp),dencl);
sys11f=tf(1,denpr);
sys21f=tf(denp,denpr);
%---------------------------------------------------
%Frequency responses
w=logspace(-1,1,200);
m11f=squeeze(bode(sys11f,w));
subplot(3,3,1)
pl=loglog(w,m11f,[10^-2 10^2], [1 1]);
set(pl,'Linewidth',AM_bode_linewidth);
axis([0.1 10 0.05 5]); 
set(gca, 'XTick', [0.1 1 10], 'XMinorGrid', 'off');
set(gca, 'YTick', [0.1 1 10], 'YMinorGrid', 'off'); 
title('PCF'); ylabel('wr');
m11=squeeze(bode(sys11,w));
subplot(3,3,2)
pl=loglog(w,m11,[10^-2 10^2], [1 1]);
set(pl,'Linewidth',AM_bode_linewidth);
axis([0.1 10 0.05 5]); 
set(gca, 'XTick', [0.1 1 10], 'XMinorGrid', 'off');
set(gca, 'YTick', [0.1 1 10], 'YMinorGrid', 'off'); 
title('PC'); ylabel('ud');
m12=squeeze(bode(sys12,w));
subplot(3,3,3)
pl=loglog(w,m12,[10^-2 10^2], [1 1]);
set(pl,'Linewidth',AM_bode_linewidth);
axis([0.1 10 0.05 5]); 
set(gca, 'XTick', [0.1 1 10], 'XMinorGrid', 'off');
set(gca, 'YTick', [0.1 1 10], 'YMinorGrid', 'off'); 
title('P'); ylabel('yd');
%-------------------------
subplot(3,3,4)
m21f=squeeze(bode(sys21f,w));
pl=loglog(w,m21f,[10^-2 10^2], [1 1]);
set(pl,'Linewidth',AM_bode_linewidth);
axis([0.1 10 0.2 10]); 
set(gca, 'XTick', [0.1 1 10], 'XMinorGrid', 'off');
set(gca, 'YTick', [0.1 1 10], 'YMinorGrid', 'off'); 
title('CF'); ylabel('ur'); xlabel('omega');
m21=squeeze(bode(sys21,w));
subplot(3,3,5)
pl=loglog(w,m21,[10^-2 10^2], [1 1]);
set(pl,'Linewidth',AM_bode_linewidth);
axis([0.1 10 0.2 10]); 
set(gca, 'XTick', [0.1 1 10], 'XMinorGrid', 'off');
set(gca, 'YTick', [0.1 1 10], 'YMinorGrid', 'off'); 
title('C'); ylabel('un'); xlabel('omega');
m22=squeeze(bode(sys22,w));
subplot(3,3,6)
pl=loglog(w,m22,[10^-2 10^2], [1 1]);
set(pl,'Linewidth',AM_bode_linewidth);
axis([0.1 10 0.2 10]); 
set(gca, 'XTick', [0.1 1 10], 'XMinorGrid', 'off');
set(gca, 'YTick', [0.1 1 10], 'YMinorGrid', 'off'); 
title('I'); ylabel('yn'); xlabel('omega');

amprint('procctrl-freq.eps');
