%% Specify Interdependent Matrix Variables
% Consider three matrix variables, X, Y, and Z, with the following structure.
% $$X = \left( {\matrix{
%    x & 0  \cr
%    0 & y  \cr
%
%  } } \right),\quad Y = \left( {\matrix{
%    z & 0  \cr
%    0 & t  \cr
%
%  } } \right),\quad Z = \left( {\matrix{
%    0 & { - x}  \cr
%    { - t} & 0  \cr
%
%  } } \right),$$
% where x, y, z, and t are independent scalar variables.  To specify such a triple, first define the two independent variables, X and Y, which are both Type 1.

setlmis([]); 
[X,n,sX] = lmivar(1,[1 0;1 0]);
[Y,n,sY] = lmivar(1,[1 0;1 0]);

% The third output of lmivar gives the entry-wise dependence of X and Y on the decision variables \left(x_1 ,x_2 ,x_3 ,x_4 \right):=\;\left(x,y,z,t\right)\ldotp

sX
sY

% Using lmivar, you can now specify the structure of the Type 3 variable Z in terms of the decision variables x_1 =x and x_4 =t.

[Z,n,sZ] = lmivar(3,[0 -sX(1,1);-sY(2,2) 0]);

% Because sX(1,1) refers to x_1 and sY(2,2) refers to x_4, this expression defines the variable Z as:
% $$Z = \left( {\matrix{
%    0 & { - {x_1}}  \cr
%    { - {x_4}} & 0  \cr
%
%  } } \right) = \left( {\matrix{
%    0 & { - x}  \cr
%    { - t} & 0  \cr
%
%  } } \right).$$
% Confirm this results by checking the entry-wise dependence of Z on its decision variables.

sZ

%
% Copyright 2012 The MathWorks, Inc.