assign is used to explicitly assigning the value obtained when applying the command double on an sdpvar object.

Note, assign does not replace or constrain the variable with a particular value. It is only used for initial values in nonlinear solvers. Hence, only used when the option usex0 in sdpsettings is activated.

Syntax

assign(X,Y)

Examples

Variables are initialized as NaN

x = sdpvar(1,1);
double(x)

ans =
    NaN

By using assign, the current value can be altered

assign(x,1)
double(x)

ans =
    1

By default, inconsistent assignments generate an error message.

t = sdpvar(1,1);x = [t t];
assign(x,[1 2])
??? Error using ==> sdpvar/assign
Inconsistent assignment

With a third argument, a least squares assignment is obtained

t = sdpvar(1,1);x = [t t];
assign(x,[1 2],1)
double(x)

ans =

    1.5000    1.5000

Related commands

sdpvar, double, replace