%  Example 4.6.  Infinity-norm computation.
clear
%  Define the closed loop system:
p1=4; p2=0.1; k1=10; k2=0.01; k3=10; k4=150; a=0.4; b=4;
Acl=[-p1  0  -k1*k4    k1
      k2 -p2    0      0
	  0   1     0      0
	  0   0  k4*(b-a) -b ];
Bcl=[ k1*k4     0   -k1*k4
        0     k2*k3    0
        0       0      0
     k4*(a-b)   0   k4*(b-a)];
Ccl=[0 0 -1  0
     0 0 -k4 1];
Dcl=[1  0  0
     k4 0 -k4];
%  Compute the principal gains of the closed loop system.
w=logspace(-2,3,200);
Gcl=pck(Acl,Bcl,Ccl,Dcl);
fr=frsp(Gcl,w);
pgains=vsvd(fr);
%  Plot the principle gains.
figure(1)
set(0,'DefaultAxesFontName','times')
set(0,'DefaultAxesFontSize',16)
set(0,'DefaultTextFontName','times')
clf
vplot('liv,lm',pgains)
xlabel('Frequency (rad/sec)')
ylabel('Magnitude')
axis([.01 1000 .1 1000])
grid
%  The infinity-norm is the maximum over frequency of the maximum 
%  principal gain.
[nr,nc]=size(pgains);
Hinf=max(pgains(1:nr-1,1))
%  An alternative algorithm for computing upper and lower bounds on 
%  the infinity-norm is given in the Mu-Synthesis and Analysis Toolbox.
temp=hinfnorm(Gcl);
%  The infinity-norm is given as the average of the bounds.
Hinf=(temp(1)+temp(2))/2
