%  Example 6.8.  Stability robustness calculation for a LQR subject to an 
%    input multiplicative perturbation.
clear
%  Define the plant model.
A=[0 -1   0   0
   0  0   0 -1.6
   0  0   0  -1
   0 1.8  0   0];
B=[ 0   0
   -11  0
    0   0
    0  -12];
%  Define the cost function parameters.
C=[1 0 0 0
   0 0 1 0];
Q=C'*C;
R=eye(2);
%  Find the steady-state LQR gain. 
K=lqr(A,B,Q,R)
%  Generate the closed loop system with the transfer function Mydwd.
Mydwd=pck(A-B*K,B,-K,zeros(2));
%  Compute the infinity-norm of Mydwd.
hinfnorm(Mydwd)
%  Compute the frequency response of Mydwd.
w=logspace(-1,2);
fr = frsp(Mydwd,w);
%  Compute the principle gains of Mydwd.
pg=vsvd(fr);
%  Plot the principle gains.
set(0,'DefaultAxesFontName','times')
set(0,'DefaultAxesFontSize',16)
set(0,'DefaultTextFontName','times')
figure(1)
clf
vplot('liv,lm',pg)
xlabel('Frequency (rad/sec)')
ylabel('Magnitude')
grid
