aminit;					% initialize MATALB

%Simulation of the six step responses for the basic loop
%The simulation is based on 
%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.5;
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);
%---------------------------------------------------
%Simulation
t=0:0.01:30;
y11=step(sys11,t);
y12=step(sys12,t);
y21=step(sys21,t);
y22=step(sys22,t);
y11f=step(sys11f,t);
y21f=step(sys21f,t);
subplot(3,3,1)
pl=plot(t,y11f);
set(pl,'Linewidth',AM_data_linewidth);
axis([0 30 0 1.5])
title('PCF'); ylabel('wr');
subplot(3,3,2)
pl=plot(t,y11);
set(pl,'Linewidth',AM_data_linewidth);
axis([0 30 0 1.5])
title('PC'); ylabel('ud');
subplot(3,3,3)
pl=plot(t,y12);
set(pl,'Linewidth',AM_data_linewidth);
axis([0 30 -0.5 1.0])
title('P'); ylabel('yd');
%---------------------
subplot(3,3,4)
pl=plot(t,y21f);
set(pl,'Linewidth',AM_data_linewidth);
axis([0 30 0 2.0]);
title('CF'); ylabel('ur'); xlabel('t');
subplot(3,3,5)
pl=plot(t,y21);
set(pl,'Linewidth',AM_data_linewidth);
axis([0 30 0 1.5])
title('C'); ylabel('un'); xlabel('t');
subplot(3,3,6)
pl=plot(t,y22);
set(pl,'Linewidth',AM_data_linewidth);
axis([0 30 -0.5 1.0])
title('I'); ylabel('yn'); xlabel('t');

amprint('procctrl-stepsim.eps');
