%% Specify Additional Loop Opening for Sensitivity Function Calculation
% Calculate the inner-loop sensitivity at the output of G2, with the outer loop open.
%
% Create a model of the system by specifying and connecting the numeric plant models, tunable controllers, and AnalysisPoint blocks. G1 and G2 are plant models, C1 and C2 are tunable controllers, and X1 and X2 are AnalysisPoint blocks that mark potential loop-opening locations.

G1 = tf(10,[1 10]);
G2 = tf([1 2],[1 0.2 10]);
C1 = tunablePID('C','pi');
C2 = tunableGain('G',1);
X1 = AnalysisPoint('X1');
X2 = AnalysisPoint('X2');
T = feedback(G1*feedback(G2*C2,X2)*C1,X1);

%
% Calculate the sensitivity, S, at X2, with the outer loop open at X1.

S = getSensitivity(T,'X2','X1');
tf(S)

% Copyright 2012 The MathWorks, Inc.