%% Single Input, Single Output (SISO) Loop Sensitivities
% Consider PI controller for a dominantly 1st-order plant, with the closed-loop bandwidth of 2.5 rads/sec. Since the problem is SISO, all gains are the same at input and output.

gamma = 2; tau = 1.5; taufast = 0.1; 
P = tf(gamma,[tau 1])*tf(1,[taufast 1]); 
tauclp = 0.4; 
xiclp = 0.8; 
wnclp = 1/(tauclp*xiclp); 
KP = (2*xiclp*wnclp*tau - 1)/gamma; 
KI = wnclp^2*tau/gamma; 
C = tf([KP KI],[1 0]);

%
% Form the closed-loop (and open-loop) systems with loopsens, and plot Bode plots using the gains at the plant input.

loops = loopsens(P,C); 
bode(loops.Si,'r',loops.Ti,'b',loops.Li,'g')

%
% Finally, compare the open-loop plant gain to the closed-loop value of PSi.

bodemag(P,'r',loops.PSi,'b')

% Copyright 2015 The MathWorks, Inc.