% MULT_NONLIN_LURE_LMI: Finding a quadratic Lyapunov function to prove 
% stability of a Lur'e system with multiple sector nonlinearities 

% Input data 
A = zeros(3,3); 
B = [0 0 1; ...
     1 0 0; ...
     0 1 0]; 
C = [ 1  0  0; ...
      0  1  0; ...
     -2 -2 -2];
x0 = [1 0 0]';
l = [0.98 0.95 0.96];
u = [1.05 1.12 1.10];
alpha = 0.2; 

% Solution 
sigma = l.*u;
nu = (l+u)/2;
F = diag(sigma);
G = diag(nu);
[n, m] = size(A); 

cvx_begin sdp
    variable P(n,n) symmetric 
    variable D(n,n) diagonal 
    P >= eye(n)
    [ A'*P + P*A + alpha*P - C'*D*F*C   P*B + C'*D*G; ...
      B'*P + D*G*C                      -D          ] <= 0
cvx_end
taus = diag(D);

% Displaying results 
if isequal( cvx_status, 'Solved' ) 
    display(P) 
    display(taus) 
end

