%% Feedback Loop With Analysis Point Inserted by connect
% Create a model of the following block diagram from r to y. Insert an analysis point at an internal location, u.
%
% Create C and G, and name the inputs and outputs.

C = pid(2,1); 
C.InputName = 'e';  
C.OutputName = 'u';
G = zpk([],[-1,-1],1);
G.InputName = 'u';  
G.OutputName = 'y';

%
% Create the summing junction.

Sum = sumblk('e = r - y');

%
% Combine C, G, and the summing junction to create the aggregate model, with an analysis point at u.

T = connect(G,C,Sum,'r','y','u')

%
% The resulting T is a genss model. The connect command creates the AnalysisPoint block, AnalysisPoints_, and inserts it into T. To see the name of the analysis point channel in AnalysisPoints_, use getPoints.

getPoints(T)

%
% The analysis point channel is named 'u'. You can use this analysis point to extract system responses. For example, the following commands extract the open-loop transfer at u and the closed-loop response at y to a disturbance injected at u.

L = getLoopTransfer(T,'u',-1);
Tuy = getIOTransfer(T,'u','y');

% T is equivalent to the following block diagram, where AP_u designates the AnalysisPoint block AnalysisPoints_ with channel name u.
%
% Copyright 2015 The MathWorks, Inc.