%% Disk-Based Gain Margin for Specified Gain-Variation Range
% Determine the disk-based gain margin corresponding to gain variations between 90% and 160% of the nominal value, and phase variations from -15 to +15 degrees.

gainRange = [0.9,1.6];
phaseRange = [-15,15];
DGMt = getDGM(gainRange,phaseRange,'tight')

% The 'tight' constraint models the smallest disk that delivers target gain and phase variations. This disk is modeled with gain variation that skews toward gain increase.
% Alternatively, you can use the 'balanced' option to constrain the disk-based gain margin to a symmetrical range of the form gmin = 1/gmax. This means that the gain can increase or decrease by equal amount.

DGMb = getDGM(gainRange,phaseRange,'balanced')

% Visualize the range of simultaneous gain and phase variations corresponding to both gain ranges.

diskmarginplot([DGMt;DGMb]) 

% The balanced range DGMb models a larger, symmetric gain range (gmin = 1/gmax) and larger phase variations than the ones you specify. If you are confident that gain varies more in one direction than the other in your system, then this balanced model might be overly conservative.
%
% Copyright 2019 The MathWorks, Inc.