%% Loop-Gain Requirement without Stability Constraint on Inner Loop
% Create requirements that specify a minimum loop gain of 20 dB (100) at 50 rad/s and a maximum loop gain of -20 dB (0.01) at 1000 rad/s on the inner loop of the following control system.
%
% Create the maximum and minimum loop gain requirements.

RMinGain = TuningGoal.MinLoopGain('X2',50,100);
RMaxGain = TuningGoal.MaxLoopGain('X2',1000,0.01);

%
% Configure the requirements to apply to the loop gain of the inner loop measured with the outer loop open.

RMinGain.Openings = 'X1';
RMaxGain.Openings = 'X1';

% Setting Req.Openings tells the tuning algorithm to enforce the requirements with a loop open at the specified location. With the outer loop open, the requirements apply only to the inner loop.
%
% By default, tuning using TuningGoal.MinLoopGain or TuningGoal.MaxLoopGain imposes a stability requirement as well as the minimum or maximum loop gain. Practically, in some control systems it is not possible to achieve a stable inner loop. In that case, remove the stability requirement for the inner loop by setting the Stabilize property to false.

RMinGain.Stabilize = false;
RMaxGain.Stabilize = false;

% When you tune using either of these requirements, the tuning algorithm still imposes a stability requirement on the overall tuned control system, but not on the inner loop alone.
% Copyright 2012 The MathWorks, Inc.