%  Example 2.3.  Computes the principle gains.
clear
%  Define the state model matrices.
A=[-1  2
    0 -3];
B=[1 0
   0 4];
C=[1  1
   1 -1];
D=zeros(2);
%  Define the frequencies for computing the principle gains.
w=logspace(-2,2);
%  Define an identity matrix with the right dimensions.
I=eye(size(A));
%  Compute the principle gains.
for k=1:50,
  Hjw=C*inv(j*w(k)*I-A)*B;
  Pgains(:,k)=svd(Hjw);
  end
%  Plot the results.
set(0,'DefaultAxesFontName','times')
set(0,'DefaultAxesFontSize',16)
set(0,'DefaultTextFontName','times')
figure(1)
clf
semilogx(w,20*log10(Pgains))
xlabel('Frequency (rad/sec)')
ylabel('Gain (dB)')
grid
%
%  Alternative code uses the sigma command:
figure(2)
clf
sigma(A,B,C,D)
