% The Landau Bechmark
% A flexible Transmission
% A not so succesful design

oldboxes
ts=0.05;

wv = logspace(-0.5,log(pi/ts)/log(10),500);
a0 = [1 -1.41833 1.58939 -1.31608 0.88642];
b0 = [0 0 0 0.28261 0.50666];
a05 = [1 -1.99185 2.20265 -1.84083 0.89413];
b05 = [0 0 0 0.10276 0.18123];
a1 = [1 -2.09679 2.31962 -1.93353 0.87129];
b1 = [0 0 0 0.06408 0.10407];
sys0=tf(b0,a0,ts)
sys05=tf(b05,a05,ts)
sys1=tf(b1,a1,ts)
figure(1)
sigma(sys0,sys05,sys1,wv)

amc = polybutt(4,20,60);
am = polyc2d(amc,ts);
aoc = polybutt(4,56,45);
ao = polyc2d(aoc,ts);
sfact = 1;
rfact = [1 -1];
tfact = 1; 
[r,s,t]=rstd(1,b0,a0,tfact,am,ao,rfact,sfact);

trldn1 = yusignal(0:ts:6,1,0,-0.1,4);
yu0 = yusimd(b0,a0,r,s,t,trldn1);
yu05 = yusimd(b05,a05,r,s,t,trldn1);
yu1 = yusimd(b1,a1,r,s,t,trldn1);
figure(2);
yupl(yu0)
yush(yu05,'r--')
yush(yu1,'b-.');
hold on
plot([1 3.5],[1.1 1.1])
plot([1 3.5],[0.9 0.9])
hold off

fb = tf(s,r,ts);
ff = tf(t,r,ts);
sens0=1/(1+fb*sys0);
sens05=1/(1+fb*sys05);
sens1=1/(1+fb*sys1);
figure(3)
grid on
sigma(sens0,sens05,sens1)
figure(4)
grid on
nyquist(fb*sys05)
axis([-2 2 -5 5])








amc = polybutt(4,20,60);
am = polyc2d(amc,ts);
aoc = polybutt(5,36,45);
ao = polyc2d(aoc,ts);
ws=8.5;
zs=0.1;
rfactc = [1 2*ws*zs ws^2];
rfact = polyc2d(rfactc,ts);
rfact = conv([1 -1],rfact);
tfact = 1; 
[r2,s2,t2]=rstd(1,b0,a0,tfact,am,ao,rfact,sfact);
fb = tf(s2,r2,ts);
ff = tf(t2,r2,ts);
sens0=1/(1+fb*sys0);
sens05=1/(1+fb*sys05);
sens1=1/(1+fb*sys1);
figure(3)
grid on
sigma(sens0,sens05,sens1)
figure(4)