% Chapter 9: Figure 9.63
%
%   Remotely controlled vehicle closed-loop system
%   Bode plot for K=4.44, 10, and 20.
%
w=logspace(0,1,200); K=[20,10,4.44];
%
for i=1:3
 numgc=K(i)*[1 2]; dengc=[1 1]; sysgc=tf(numgc,dengc);
 numg=[1]; deng=[1 2 4]; sysg=tf(numg,deng);
 syss=series(sysgc,sysg); sys=feedback(syss,[1]);
 [mag,phase,w]=bode(sys,w);
 mag_save(i,:)=mag(:,1,:);
end
%
loglog(w,mag_save(1,:),w,mag_save(2,:),w,mag_save(3,:))
xlabel('Frequency (rad/s)'), ylabel('Magnitude (dB)'), grid on