%% Complementary Sensitivity Function at a Location
% Compute the complementary sensitivity at the plant output, X, of the control system of the following illustration.
%
% Create a model of the system by specifying and connecting a numeric LTI plant model G, a tunable controller C, and the AnalysisPoint block X. Use the AnalysisPoint block to mark the location where you assess the complementary sensitivity, which in this example is the plant output.

G = tf([1],[1 5]);
C = tunablePID('C','p');
C.Kp.Value = 3;
X = AnalysisPoint('X');
CL = feedback(G*C,X);

%
% CL is a genss model that represents the closed-loop response of the control system from r to y. Examine the Control Design Blocks of the model.

CL.Blocks

% The model's blocks include the AnalysisPoint block, X, that identifies the analysis-point location.
%
% Calculate the complementary sensitivity, T, at X.

T = getCompSensitivity(CL,'X')

%
% getCompSensitivity preserves the Control Design Blocks of CL, and returns a genss model. To get a numeric model, you can convert T to transfer-function form, using the current value of the tunable block.

Tnum = tf(T)

% Copyright 2012 The MathWorks, Inc.