%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%The result shows that a PI controller 
%adds the steady state accuracy, and
%a lag compensator approximates to 
% a PI controller.
%
%The plant model is Gp=1/(s+1)(s+5).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%P control:

%gain:
Kp=13;

%closed-loop TF
num=[0 0 Kp];
den=[1 6 5+Kp];
sys=tf(num,den)

%step response:
step(sys,60);
grid;

hold on;
pause;
%%%%%%%%%%%%%%%%%%%PI control:

K=13.21;
a=0.1;

%closed-loop TF
num1=[0 0 K K*a];
den1=[1 6 5+K K*a];
sys1=tf(num1,den1)

%step response:
step(sys1,60);

hold on;
pause;
%%%%%%%%%%%%%%%%%%%Lag compensation:

K=15;
a=1;
b=0.1;

%closed-loop TF
num2=[0 0 K];
den2=[1 5.1 0.5+K];
sys2=tf(num2,den2)

%step response:
step(sys2,60);

hold off;

