% script for Lag Compensator design
% Pole , zero 

num = 2;
den=[1 10 24 0]; 
bode(num,den)
hold on
grid on
title(' Bode Example of plant addition, Plant = 2/[s(0.25s+1)(s/6+1)')
pause
zero = input('enter new zero =  ')

n=[1/zero 1];
d=[1/(0.1*zero) 1]; 
bode(n,d)
pause
tnum=conv(num,n);
tden=conv(den,d);
bode(tnum,tden)
title(' Bode Example of plant addition, Plant+ Lag')

K = input('enter new gain K =  ')
 
tnum=conv(K*num,n);
tden=conv(den,d);
bode(tnum,tden)
title(' Bode Example of plant addition, gain adjusted, Plant* Lead')

sys=tf(tnum,tden)
[Gm,Pm,Wcg,Wcp] = margin(sys)
