Assume we are given the following semidefinite program (SDP) written in MATLAB using CVX:
A=[1 0 1; 0 3 7; 1 7 5];
C=[1 2 3; 2 9 0; 3 0 7];
n=size(C,1);
cvx_begin
variable X(n,n) symmetric;
minimize trace(C*X)
subject to
trace(A*X) == 1;
X == semidefinite(n);
cvx_end
where the optimum is found to be -0.385827
. How can one extract the solution for $X$, that is the values of the elements of the matrix $X$?
Best Answer
If CVX status is
Solved
, after CVX execution completes, the declared variables become double precision MATLAB variables, numerically populated with the optimal variable values. SoX
is a double precision variable containing the optimal value ofX
. You can display it, assign it to another variable, or anything else you can do with it in standard MATLAB.In your problem,
This is covered in the CVX users' Guide