# Disciplined convex programming error: Only scalar quadratic forms can be specified in MATLAB's CVX

I want to minimize $$W\, \text{tr}\left([A-Y_{pie}][A-Y_{pie}]^T\right) + \lambda\Vert A\Vert\, \enspace ,$$ however, I encounter the following problem:

Disciplined convex programming error: Only scalar quadratic forms can be specified in CVX.


Would you like to solve with this, please? Thank you!

Ypie=T*Y; % Y is k*n matrix,T is k*k matrix  ,W is a n*k matrix

lamda=0.01;

cvx_begin

variable A(K,n)

minimize (W.*trace((A-Ypie)*(A-Ypie)')+lamda*norm_nuc(A))

cvx_end

• Does not make sense to minimize a matrix objective. Do you mean $\text{trace} (W...)$ perhaps? – Johan Löfberg Nov 10 '14 at 11:10

So in your case, once CVX sees (A-Ypie)*(A-Ypie)', it declares a DCP error. This is proper behavior even though the trace of this quantity is indeed convex. After all, only the diagonal elements of this expression are convex; the rest are non-convex. You're never allowed to construct a non-convex (or non-concave) expression in CVX, even if you end up throwing it away.
To fix this, you have to recognize that this trace quantity is actually the square of the Frobenius norm of A-Ypie. So sum_square(A(:)-Ypie(:)) will do, as will square_pos(norm(A-Ypie,'fro')), or (in CVX 3.0 beta only) norm(A-Ypie,'fro')^2.