Hi everyone, I just started to use CVX package. I found the unexpected error below.
Strangely enough, though, if I change the definition of F
to be (ones(n)*1.01  kron(tmpC, tmpC)) / 2
(which does not have any zero element, unlike the original F
) then everything goes smoothly (though the dual SDP becomes infeasible). So I guess the problem has something to do with zero coefficient.
 Update
The problem is solved by typing clear all
and rerun the script. This adhoc solution is from http://ask.cvxr.com/t/errorfunctionsubsindexisnotdefinedforvaluesofclassstruct/3803.

Error message:
Status: Error Optimal value (cvx_optval): NaN Array indices must be positive integers or logical values. Error in cvx_sdpt3>solve (line 211) Avec{end}{end+1} = reshape( ( str_3 * str_2 ) * reshape( At(ti,:), nt, nv * m ), nt2 * nv, m ); Error in cvx_solve (line 399) [ x, status, tprec, iters, y ] = shim.solve( At, b, c, cones, params ); Error in cvx_finish Error in cvx_end (line 11) evalin( 'caller', 'cvx_finish' ); Error in test0312 (line 17) cvx_end

Code
n = 4 tmpA = [1 1; 1 1] tmpB = [0 1; 1 0] tmpC = [1 1; 1 1] F = (ones(n)  kron(tmpC, tmpC)) / 2 D1 = kron(tmpA, tmpB) D2 = kron(tmpB, tmpA) cvx_begin sdp variable G(n,n) symmetric maximize(sum(sum(G.*F))) G.*F.*D1 <= eye(n) G.*F.*D2 <= eye(n) cvx_end

CVX Version
CVX: Software for Disciplined Convex Programming (c)2014 CVX Research Version 3.0beta, Build 1183 (dda2109) Sun Dec 17 18:58:10 2017  Installation info: Path: D:\software\matlab\cvxw64\cvx MATLAB version: 9.4 (R2018a) OS: Windows 10 amd64 version 10.0 Java version: 1.8.0_144