%% H-Infinity Controller Synthesis
% Synthesize a controller using different target performance levels. The plant in this example is based on the augmented plant model used in docid:robust_gs.btuqw4p.  Load the plant.

load hinfsynExData P
size(P)

%
% This plant has five outputs and four inputs, where the last two outputs are measurement signals to provide to the controller, and the last input is a control signal. Compute an {H_\infty }-optimal controller.

ncont = 1; 
nmeas = 2; 
[K1,CL,gamma] = hinfsyn(P,nmeas,ncont);

%
% The resulting two-input, one-output controller has the same number of states as P.

size(K1)

%
% The optimal performance level achieved by this controller is returned as gamma. This value is the {H_\infty } norm of the closed-loop system CL.

gamma

%
% You can examine the singular value plot of the closed-loop system to confirm that its largest singular value does not exceed gamma.

sigma(CL,ss(gamma))
ylim([-120,20]);

%
% Copyright 2018 The MathWorks, Inc.