%Example 7.4 produces Figure 7.7
%
close all;clear all;
w=0.5;
%Uncertainty region:
gf=uncreg(w);
plot(real(gf),imag(gf),'--');
grid;axis('square');hold on;

k=2.5;tau=2.5;theta=2.5;
%Norminal Plant option 1:
gf1=k/(j*w*tau+1);
%Uncertainty radius
r1=max(abs(gf1-gf));
phi=0:0.1:2*pi+0.1;
uc1=gf1+r1*exp(-j*phi);
plot(real(uc1),imag(uc1),'-',real(gf1),imag(gf1),'+');

%Norminal Plant option 2:
gf2=gf1*exp(-j*w*theta);
%Uncertainty radius
r2=max(abs(gf2-gf));
uc2=gf2+r2*exp(-j*phi);
plot(real(uc2),imag(uc2),'-',real(gf2),imag(gf2),'o');


%Norminal Plant option 3:
%First guess:
gf3=(3*exp(-j*w*2)/(j*w*2+1)+2*exp(-j*w*3)/(j*w*3+1))/2;
%Optimal plant with minimized radius:
x=fmins('maxrad',[real(gf3);imag(gf3)],[],[],gf);
gf3=x(1)+i*x(2);
%Uncertainty radius
r3=max(abs(gf3-gf));
uc3=gf3+r3*exp(-j*phi);
plot(real(uc3),imag(uc3),'-',real(gf3),imag(gf3),'*');
