% include 5th-order controller from mu design as comparison

ka = [24.61, -23.29, -0.679,  0.9484, -3.736
      33.43, -8.551, -0.9586,  18.27, -12.61
      1.082, -1.065, -0.1379,   9.683, -2.278
      1.524, -20.46, -9.765,  -13.63,  42.37
      6.064, -14.27,  -2.32,  -42.79, -70.38];
kb = [-5.062; 2.833; 0.2381; 2.39; 2.473];
kc = [8.221, 3.206, 0.2427, -2.415, 2.475];
kd = -0.4762;
k4 = ss (ka, kb, kc, kd);

del = tf ([-0.03 1], [0.03 1]);   % delay 60 ms

% We will use the worst case model with a = 1, most unstable pole
g = tf (1, [1 0 -1]) * del;

w0 = 8;
[k, cl, gam, info] = ncfsyn (g, w0, 1);
fprintf ('gamma = %6.3f\n', gam);
sigma (k, k4, '--')
axis ([1 200 -10 35])
grid on
pause


w1 =  ellipfilt (4, 1.5, 35.8, 40.8);
% adjust these parameters so that k fits the requirement of -6 dB above
% 50 rad/s. These parameters depend on w0

[k, cl, gam, info] = ncfsyn (g, w0*w1, 1);
fprintf ('gamma = %6.3f\n', gam);

sigma (k, k4, '--')
axis ([1 200 -10 35])
grid on
