Help:cvx codes about convex

norms is a useful CVX function, but it is irrelevant to the error at hand, which is that the argument of norm must be affine, which ri is not. The "illegal’ expression is a norm of a norm, which violates CVX’s rules. norms could however allow ri(j)=norm(Anchors(j,1:2)-X1’); to be pulled out of the for loop.

Fortunately, this can be reformulated to not have norm of norm. Just introduce ri_no_norm(j) as ri_no_norm(j)=Anchors(j,1:2)-X1'; And then use norm([2*ri_no_norm;yi-1],2)<=yi+1; I added ri_no_norm rather than changing ri, because ri is also used elsewhere in your program…