% Control tuning optimization #2.

% Open the model:
optsim

% Set initial values:
pid0 = [0.63, 0.0504, 1.9688];
a1 = 3; a2 = 43;

% Set options:
options = ...
optimset('Display', 'iter', ...
'TolX', 0.001, ...
'TolFun', 0.001);

% Run the optimization:
pid = ...
fminimax(@trackmmobj, pid0 , [], [], [], [], [], [], 'trackmmcon', options, a1, a2)

Kp = pid(1); Ki = pid(2); Kd = pid(3); 