
% ExplX5_1.m : Extra example for chapter 5. After remark p. 167

% 1. System L1 = 2/s(s+1). Illustrates Bode's sensitivity integral

L1 = nd2sys(2, [1 1 0]);
w = logspace(-2,1,121);
S1 = minv(madd(1,L1));
sw1 = frsp(S1,w);

vplot('liv,lm',sw1,1,':');      % Regular plot (lnS vs. lnw)
vplot('iv,lm',sw1,1,':');       % Linear axis for frequency (lnS vs. w)
title('L1(s)=2/s(s+1); The areas above and below 1 are equal');
% We see that the area at high frequencies also contributes so
% the peak itself need not be very large.

% 2. System L = 2(-0.2s+1) / s(s+1)(0.2s+1)
%  |L| is same as above but we have added term (-0.2s+1)/(0.2s+1)

L2 = nd2sys([-0.4 2], [0.2 1.2 1 0]);
S2 = minv(madd(1,L2));
sw2 = frsp(S2,w);

%Plot both systems
vplot('liv,lm',sw2,sw1,'--',1,':'); % Regular plot  (lnS vs. lnw)
vplot('iv,lm',sw2,sw1,'--',1,':');  % Linear axis for frequency  (lnS vs. w)
title('Solid line: With RHP-zero; BOTH cases: Areas equal');
% In BOTH cases the areas of lnS below and above 1 must be equal.
%  BUT with the RHP-zero the peak must be higher,  
%  see Thm.5.2 where only frequencies up to about z=5 count.



