function loopviewPlot(CG,GC)
% Constructs INFO output of LOOPTUNE from counterpart for SYSTUNE.

%   Copyright 2003-2014 The MathWorks, Inc.
ny = size(GC,1);
nu = size(CG,1);

% Sensitivity functions
if nu>ny
   % Output sensitivity
   S = feedback(eye(ny),GC,+1);
   T = S-eye(ny);
else
   % Input sensitivity
   S = feedback(eye(nu),CG,+1);
   T = S-eye(nu);
end

% Determine the crossover range and set frequency range
[sv,w] = sigma(blkdiag(GC,CG));
sv = sv(max(sv,[],2)>1 & min(sv,[],2)<1,:);
if isempty(sv)
   wcmin = 1;   wcmax = 1;
else
   wcmin = w(find(sv(end,:)<1,1));
   wcmax = w(find(sv(1,:)<1,1));
end
fmin = 10^floor(log10(wcmin)-1.5);
fmax = 10^ceil(log10(wcmax)+1.5);

% Open-loop view
clf
h = sigmaplot(GC,'b',CG,'b--',S,'g',T,'r');
for ct=1:numel(h.Response)
   h.Response(ct).setstyle('LineWidth',1.75)
end
legend('GC','CG','S','T','Location','NorthEast')
% Grid and limits
h.AxesGrid.Grid = 'on';
if nu>ny
   h.AxesGrid.Title = getString(message('Control:tuning:strLoopView4'));
else
   h.AxesGrid.Title = getString(message('Control:tuning:strLoopView3'));
end
ax = getaxes(h.AxesGrid);
Ylim = get(ax,'YLim');
Ylim(1) = max(Ylim(1),-60);
Ylim(2) = min(Ylim(2),+60);
set(ax,'XLim',[fmin,fmax],'YLim',Ylim)
