%% Loop Shaping With ncfsyn
% The following code shows how ncfsyn can be used for loop-shaping.

s = zpk('s');
G = (s-1)/(s+1)^2;
W1 = 0.5/s; 
[K,CL,GAM] = ncfsyn(G,W1);
sigma(G*K,'r',G*W1,'r-.',G*W1*GAM,'k-.',G*W1/GAM,'k-.')

% The singular value plot of the achieved loop G*K is equal to that of the target loop G*W1 to within plus or minus GAM (in dB).
% Copyright 2015 The MathWorks, Inc.