% Chapter 10: Figure 10.31
%
%   Rotor winder control uncompensated system Bode diagram 
%   for lead controller design. 
%
clear
K=500;
numg=[1]; deng=[1 15 50 0]; sysg=tf(numg,deng);
sys=K*sysg;
%
[Gm,Pm,Wcg,Wcp]=margin(sys);
%
Phi=(60-Pm)*pi/180; 
alpha=(1+sin(Phi))/(1-sin(Phi))
[mag,phase,w]=bode(sys);
mag_save(1,:)=mag(:,1,:);
%
M=-10*log10(alpha)*ones(length(w),1);
%
semilogx(w,20*log10(mag_save),w,M), grid
xlabel('Frequency (rad/sec)'), ylabel('Magnitude (dB)')