disp ('Loop Shaping Design')
pause

disp ('delay')

del = tf ([-0.03 1], [0.03 1]);

g = del * tf (1, [1 0 -1]);

sigma (g)
grid
axis ([0.1 100 -20 20])

disp ('Worst case system')


wk = ellipfilt (6, 1.07, 39, 38.5);

sigma (wk)
grid
axis ([1 1000 -45 5])
title ('wk')

pause

w1 = 10;

[k, ~, gam] = ncfsyn (g, w1*wk, 1);

gam

sigma (g*w1*wk, '--' , g*k, 'r', k, 'g-.')
hold on
plot ([40 40 1000], [40 -6 -6]);
axis ([0.1 1000 -90 40])
legend ('g*w1*wk', 'g*k', 'k', 'gain limit');
hold off
grid

pause

if exist ('krr', 'var'),
  sigma (k, krr, '--');
  grid on
  hold on
  plot ([40 40 1000], [40 -6 -6]);
  axis ([0.1 1000 -90 40])
  legend ('loop shaping', 'mu synthesis', 'gain limit');
  axis ([0.1 1000 -15 35])
  hold off
end

