% Fig. 6.42   Feedback Control of Dynamic Systems, 8e 
%             Franklin, Powell, Emami
%

clear all;
%close all;
clf
 
num = 86*conv([1 1],[1 2 43.25]);
p = conv([1 2 82],[1 2 101]);
den = conv([1 0 0],p);

w = logspace(-1,2,1000);

[mag,phas] = bode(num,den,w);

figure(1)

loglog(w,mag,w,ones(size(w)),'LineWidth',2);
set(findall(gcf,'type','line'),'linewidth',2);

axis([.1 100 .01 10])
%axis([.1 100 .05 2])

grid on
xlabel('\omega (rad/sec)');
ylabel('Magnitude');
title('Bode plot for Example 6.13 (a) magnitude');
%pause;

figure(2)

semilogx(w,phas,w,-180*ones(size(w)),'LineWidth',2);
set(findall(gcf,'type','line'),'linewidth',2);

grid on
xlabel('\omega (rad/sec)');
ylabel('Phase (deg)');
title('Bode plot for Example 6.13 (b) phase');
figure(1)

% actually, the GMs and PMs are slightly different for the system here
% than that described in the text, the differences arose from  
% roundoff because the initial design was done by hand.  The ideas
% are unchanged.
