%% Create Augmented Plant for H-Infinity Synthesis
% Suppose you want to synthesize a stabilizing robust controller for the system of the following diagram. The controller must also reject disturbances injected at the plant output.
%
% The plant, G, is an unstable first-order system.

G = tf(1,[1 -1]);

%
% To set up this problem for hinfsyn, insert a weighting function W1 that captures the disturbance rejection goal, and another weighting function W3 to enforce robustness. Specify these weighting functions as the inverses of the desired loop shapes for the sensitivity S and complementary sensitivity T, respectively. (See Mixed-Sensitivity Loop Shaping.)
% For this example, choose W1 with:
% Low-frequency gain of 100 (40 dB)
% 0 dB crossover at 0.5 rad/s
% High-frequency gain of 0.25 (–12 dB)
% Choose W3 to have the opposite low-frequency and high-frequency gains.

W1 = makeweight(100,[1 0.5],0.25);
W3 = makeweight(0.25,[1 0.5],100);
bodemag(W1,W3)

%
% For this example, do not specify a W2 (no restriction on control effort). Construct the augmented plant, P.

P = augw(G,W1,[],W3);

% G has one input and one output. The augmented plant has an additional input for the control signal, and additional outputs for each of the weights.

size(P)

% The inputs and outputs of P are grouped to keep track of the disturbance and control inputs and the error and measurement outputs. For example, example the output groups. Group Y1 contains the two error outputs z, and group Y2 contains the single measurement output.

P.OutputGroup

%
% You can now use P for control design. For example, use hinfsyn to design an H_{\infty } optimal controller that meets the design requirements specified by W1 and W3.

[K,CL,gamma] = hinfsyn(P); 
gamma

% Copyright 2012 The MathWorks, Inc.