Commit a4181b19 authored by Kristian Soltesz's avatar Kristian Soltesz
Browse files

code clean

parent ad22ab9e
......@@ -39,21 +39,17 @@ p = [pC(:);pF(:)];
pC = @(p)p(1:3);
pF = @(p)p(4);
w = w(:);
p(4) = max(p(4),Tmin);
% Helper functions
mdot = @(x,y)(bsxfun(@times,x,y)); % (row vector)-matrix column-wise dot
fr = @(x)permute(freqresp(x,w),[3 1 2]); % frequency response over grid
% Misc
z = 1/sqrt(2); % Filter damping
Pw = fr(P); % Frequency response
% Transfer functions
s = zpk('s');
C1 = [1;1/s;s];
C = @(p)pC(p).'*C1;
z = 1/sqrt(2); % Filter damping
F = @(p)1/((pF(p)*s)^2+2*z*pF(p)*s+1);
K = @(p)series(F(p),C(p));
S = @(p)feedback(1,series(P,K(p)));
......@@ -63,6 +59,9 @@ C_pC = @(p)C1; % dK/dpC
F_pF = @(p)(-2)*F(p)^2*s*(s*pF(p)+z); % dF/dpF
K_p = @(p)[F(p)*C_pC(p);C(p)*F_pF(p)]; % dK/dp
% Frequency responses
Pw = fr(P); % Frequency response
% Optimization
cfg = optimset('algorithm','active-set','GradConstr','on','GradObj',...
'on','Display','off','maxIter',10);
......@@ -82,17 +81,17 @@ K = minreal(K(p));
% Constraints and gradients
function [c,cEq,c_p,cEq_p]=cNL(p)
% Ms
% Sensitivity
Sw = fr(S(p));
Sm = abs(Sw);
cS = Sm-Ms;
% Mt
% Complementary sensitivity
Tw = 1-Sw;
Tm = abs(Tw);
cT = Tm-Mt;
% Mks
% Noise sensitivity
Kw = fr(C(p)*F(p));
Km = abs(Kw);
KSm = Km.*Sm*c0; % Undo regularization
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment