blkvar is used to simplify creation of block-structured variables.

You are discouraged from using this command, since it makes your code less MATLAB standard.

## Syntax

x = blkvar;


## Examples

Consider the 3x3 block matrix [A B 0;B’ C D;0 D’ E]. Using standard YALMIP and MATLAB code, we would define this using concatenations.

n = 5;
m = 3;
A = sdpvar(n,n);
B = randn(n,2);
E = sdpvar(m,m);
C = randn(2,2);
D = randn(2,m);
X = [A B zeros(n,m);B' C D;zeros(m,n) D' E];


By using a block variable, we can define blocks instead.

X = blkvar;
X(1,1) = A;
X(1,2) = B;
X(1,3) = 0;
X(2,2) = C;
X(2,3) = D;
X(3,3) = E;
X = sdpvar(X);


Dimension of 0-blocks do not have to be specified, they will be derived automatically, if possible, from the dimension of other elements. Note that we only have to define one element of symmetric pairs, YALMIP will automatically fill in the symmetric counter-part. If no symmetric counter-part is found, the corresponding block is filled with zeros. Hence, the following code is equivalent.

X = blkvar;
X(1,1) = A;
X(1,2) = B;
X(2,2) = C;
X(2,3) = D;
X(3,3) = E;
X = sdpvar(X);


Standard operators can typically be applied directly to the block variable (but it is currently recommended to convert the variable to an sdpvar object first)

X = blkvar;
X(1,1) = A;
X(1,2) = B;
X(2,2) = C;
X(2,3) = D;
X(3,3) = E;
F = [X >= 0, trace(X)==1];
% Recommended
X = sdpvar(X);
F = [X >= 0, trace(X)==1];