sdpvar is used to define YALMIPs symbolic decision variables.
Syntax
x = sdpvar(n,m)
x = sdpvar(n,m,'type')
x = sdpvar(n,m,'type','field')
x = sdpvar(dim1,dim2,dim3,...,dimn,'type','field')
sdpvar x
Examples
A square real-valued symmetric matrix is obtained with
The command above can be simplified by only giving one argument when defining a symmetric matrix or a scalar (this might not work on MATLAB 5.3 and earlier version).
We can also define the same matrix using a more verbose notation.
A fully parameterized (i.e., not necessarily symmetric) square matrix requires a third argument.
A square complex-valued fully parameterized matrix is obtained with
YALMIP tries to complete the third and fourth argument, so an equivalent command is
Variables can alternatively be defined using command line syntax (although this sometimes can be dangerous inside functions due to a bug in some versions of MATLAB.)
A lot of users seem to get stuck initially on simple things such as defining a diagonal matrix. The most important thing to remember when working with YALMIP is that almost all MATLAB operators can be applied also on sdpvar objects. Hence, we create diagonal matrices with
Or Hankel...
A typical situation is that several identical variables are needed, and a natural way to implement this is to use a loop.
A more convenient way to implement this is to use vector valued dimensions (this currently only works if all matrices are symmetric or full)
A recent addition is the support of multi-dimensional variables. This command defines a 3D variable, where each slice in the first two dimensions is symmetric.
X(:,:,1)
Linear matrix variable 3x3 (symmetric, real, 6 variables)
The following command defines a 4D variable, where each slice in the first two dimensions is fully parameterized.
X(:,:,1,1)
Linear matrix variable 3x3 (full, real, 9 variables)