%% Specifying the LMI Variables
%% Define the state-space matrices of the system

A = [  -0.8715    0.5202    0.7474    1.0778   -0.9686    0.1005;
       -0.5577   -1.0843    1.8912    0.2523    1.0641   -0.0345;
       -0.2615   -1.7539   -1.5452   -0.2143    0.0923   -2.4192;
        0.6087   -1.0741    0.1306   -2.5575    2.3213    0.2388;
       -0.7169    0.3582   -1.4195    1.7043   -2.6530   -1.4276;
       -1.2944   -0.6752    1.6983    1.6764   -0.3646   -1.7730 ];
  
B = [       0    0.8998   -0.2130    0.9835;
            0   -0.3001         0   -0.2977;
      -1.0322         0   -1.0431    1.1437;
            0   -0.3451   -0.2701   -0.5316;
      -0.4189    1.0128   -0.4381         0;
            0         0   -0.4087         0];
 
C = [      0    2.0034         0    1.0289    0.1554    0.7135;
      0.9707    0.9510    0.7059    1.4580   -1.2371    0.3174;
           0         0    1.4158    0.0475   -2.1935    0.4136;
     -0.4383    0.6489   -1.6045    1.7463   -0.3334   -0.5771];

%
%% Initialize the LMI and declare the variables

setlmis([])
lmivar(1,[6 1]);     % X 
lmivar(1,[2 0;2 1]); % S

%
%% Declare the variables with tags

X = lmivar(1,[6 1]); 
S = lmivar(1,[2 0;2 1]);

%
%% Specify the first LMI

lmiterm([1 1 1 1],1,A,'s'); 
lmiterm([1 1 1 2],C',C); 
lmiterm([1 1 2 1],1,B); 
lmiterm([1 2 2 2],-1,1);

%
%% Specify the third LMI

lmiterm([-3 1 1 2],1,1);      % 1*S*1 = S 
lmiterm([3 1 1 0],1);         % 1*I = I

%
%% Specify the whole problem

setlmis([]) 
X = lmivar(1,[6 1]); 
S = lmivar(1,[2 0;2 1]);

BRL = newlmi; 
lmiterm([BRL 1 1 X],1,A,'s'); 
lmiterm([BRL 1 1 S],C',C);
lmiterm([BRL 1 2 X],1,B); 
lmiterm([BRL 2 2 S],-1,1);

Xpos = newlmi; 
lmiterm([-Xpos 1 1 X],1,1);

Slmi = newlmi;
lmiterm([-Slmi 1 1 S],1,1);
lmiterm([Slmi 1 1 0],1);

%
%% Get internal representation

LMISYS = getlmis;

% Copyright 2012 The MathWorks, Inc.