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

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

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

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

%
% Calculate the robust performance margin of the system relative to a peak gain of 1.5, specifying the info output to access additional information about the calculation.

[perfmarg,wcu,info] = robgain(S,1.5,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 performance margin. For example, the sensitivity for k is 28. This value means that a given change dk in the normalized uncertainty range of k causes a change of about 28% of that, or 0.28*dk, in the performance margin. The margin in this case is more sensitive to delta, for which the margin changes by about 75% of the change in the normalized uncertainty range.
% Copyright 2012 The MathWorks, Inc.