%Example 2.10, Flexible loop-shaping design.
%Produce Figure 2.24
%
%Plant (2.66): G(s)=Gd(s)=2.5s(s^2+1)/(s^2+0.5^2)(s^2+2^)
%
omega=logspace(-2,3,410);
g=nd2sys(conv([1 .1e-3],[1 .1e-3 1]),conv([1 .1e-3 0.25],[1 .1e-3 4]),2.5);
gd=g;

%Controller (1.87): K(s)=1
%
c=1;
l = mmult(g,c);
s = minv(madd(1,l));
sgd = mmult(s,gd);
r1=frsp(l,omega);
time=0:0.1:20;
[A,B,C,D]=unpck(sgd);y1=vpck(step(A,B,C,D,1,time),time);
[A,B,C,D]=unpck(gd);yol=vpck(step(A,B,C,D,1,time),time);

subplot(221),vplot('liv,lm',r1,1,':')
axis([.01,100,.01,100]);
xlabel('Frequency');ylabel('Magnitude');text(10,10, 'G=Gd')
subplot(222),vplot(y1,yol,'--',0,'w:')
xlabel('Time');ylabel('y(t)');
text(5,1.5,'YOL');text(13,-0.5,'YCL');
text(13,-0.85,'(solid line)')

