% Starting CVX 
cvx_setup

%% 

% Toy example
A = [-1 0; 0 -2];
B_1 = eye(2);
B_2 = eye(2);

% Optimization
cvx_begin sdp
variable P(2,2) symmetric
variable Q(2,2)
variable g 
minimize g
subject to 
P> 0;
[P*A'+A*P+Q'*B_2'+B_2*Q B_1 P Q';...
    B_1' -g*eye(2) zeros(2,4);...
    P zeros(2,2) -eye(2) zeros(2,2);...
    Q zeros(2,4) -eye(2)]<0;
g>0
cvx_end

gamma = sqrt(g)
K = Q*inv(P)

