%% Constrain Input and Output Trajectories to Conic Sector
% Consider the following control system.
%
% Suppose that the signal u is marked as an analysis point in a Simulink model or genss model of the control system. Suppose also that G is the closed-loop transfer function from u to y. Create a tuning goal that constrains all I/O trajectories {u(t),y(t)} of G to satisfy:
% \int_0^T {{{\left( {\begin{array}{*{20}{c}}
% {y\left( t \right)}\\
% {u\left( t \right)}
% \end{array}} \right)}^T}Q\;\left( {\begin{array}{*{20}{c}}
% {y\left( t \right)}\\
% {u\left( t \right)}
% \end{array}} \right)dt}  < 0,
% for all T \ge 0. For this example, use sector matrix that imposes input passivity with index 0.5.

nu = 0.5;
Q = [0 -1;-1 2*nu];

%
% Constraining the I/O trajectories of G is equivalent to restricting the output trajectories z \left( t \right) of H = \left[ {G;I} \right] to the sector defined by:
% \int_0^T {z{{\left( t \right)}^T}Q\;z\left( t \right)dt}  < 0.
% (See About Sector Bounds and Sector Indices for more details about this equivalence.) To specify this constraint, create a tuning goal that constrains the transfer function H = \left[ {G;I} \right], which the transfer function from input u to outputs \{ y;u\}.

TG = TuningGoal.ConicSector('u',{'y';'u'},Q);

% When you specify the same signal 'u' as both input and output, the conic sector tuning goal sets the corresponding transfer function to the identity. Therefore, the transfer function constrained by TG is H = \left[ {G;I} \right] as intended. This treatment is specific to the conic sector tuning goal. For other tuning goals, when the same signal appears in both inputs and outputs, the resulting transfer function is zero in the absence of feedback loops, or the complementary sensitivity at that location otherwise. This result occurs because when the software processes analysis points, it assumes the input is injected after the output. See Mark Signals of Interest for Control System Analysis and Design for more information about how analysis points work.
% Copyright 2012 The MathWorks, Inc.