%% Responses with Some Loops Open and Others Closed
% Compute the response from r to y of the following cascaded control system, with the inner loop open, and the outer loop closed.
%
% Create a genss model of the system by specifying and connecting the numeric plant models G1 and G2, the tunable controllers C1 and C2, and the AnalysisPoint blocks X1 and X2 that mark potential loop-opening or signal injection sites.

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);
T.InputName = 'r';
T.OutputName = 'y';

% If you tuned the free parameters of this model (for example, using the tuning command systune), you might want to analyze the tuned system performance by examining various system responses.
%
% For example, compute the response of the system with the inner loop open, and the outer loop closed.

H = getIOTransfer(T,'r','y','X2');

% By default, the loops are closed at the analysis points X1 and X2. Specifying 'X2' for the openings argument causes getIOTransfer to open the loop at X2 for the purposes of computing the requested transfer from r to y. The switch at X1 remains closed for this computation.
% Copyright 2012 The MathWorks, Inc.