Note, assign does not [replace 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.
Variables are initialized as NaN
x = sdpvar(1,1); value(x) ans = NaN
By using assign, the current value can be altered
assign(x,1) value(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) value(x) ans = 1.5000 1.5000
The value can be used as an initial guess for solvers supporting this
x = sdpvar(1,1); assign(x,pi); optimize([sin(x)^2 <= .1],x,sdpsettings('usex0',1));