%% Determine Effect of Uncertainty Range on Worst-Case Response
% Consider a feedback loop with a first-order plant and a PI controller. The time constant of the plant is uncertain, and the feedback loop accounts for unmodeled dynamic uncertainty. Compute the worst-case gain of the sensitivity function Si at the plant inputs. Use the 'Sensitivity' option of wcOptions to compute how sensitive this worst-case gain is to each uncertain element.

% Create uncertain system and controller
delta = ultidyn('delta',[1 1]);
tau = ureal('tau',5,'range',[4 6]);
P = tf(1,[tau 1])*(1+0.25*delta);
C = pid(4,4);

opt = wcOptions('Sensitivity','on');
Si = inv(1 + C*P);
[wcg,~,info] = wcgain(Si,opt);

% The Sensitivity field of the info output structure includes data that reflects how much the maximum gain of the input sensitivity function changes with each uncertain element.

info.Sensitivity

% This result tells you that if the uncertainty range of delta increases by 10%, the peak input sensitivity increases by about 4.4%. Similarly, a 10% increase in the uncertainty range of tau causes about a 0.9% increase in the peak input sensitivity.
% Copyright 2018 The MathWorks, Inc.