%% Sensitivity to Uncertain Elements
% Examine the relative sensitivity of the robust stability margin to the uncertain elements of the system. Consider a model of a control system containing uncertain elements.

k = ureal('k',10,'Percent',40);
delta = ultidyn('delta',[1 1]); 
G = tf(18,[1 1.8 k]) * (1 + 0.25*delta);
C = pid(2.3,3,0.38,0.001);
CL = feedback(G*C,1);

%
% Create an options set for robstab that enables the sensitivity calculation.

opts = robOptions('Sensitivity','On');

%
% Calculate the robust stability margin, specifying the info output to access additional information about the calculation.

[stabmarg,wcu,info] = robstab(CL,opts);

%
% Examine the Sensitivity field of info.

info.Sensitivity

% The values in this field indicate how much a change in the normalized perturbation on each element affects the stability margin. For example, the sensitivity for k is 21. This value means that a given change dk in the normalized uncertainty range of k causes a change of about 21% percent of that, or 0.21*dk, in the stability margin. The margin in this case is much more sensitive to delta, for which the margin changes by about 81% of the change in the normalized uncertainty range.
% Copyright 2012 The MathWorks, Inc.