cvx_begin quiet
variable X1(2,1);
expression ri(n,1);
variable y;
expression yi(n,1);
expression h(n,1);
minimize sum(h);
subject to
y>=sum_square_abs(X1);
for j=1:n
yi(j)=y-2Anchors(j,1:2)X1+Anchors(j,1:2)(Anchors(j,1:2))’;
ri(j)=norm(Anchors(j,1:2)-X1’);
h(j)=(bi(j)^2)yi(j)-2bi(j)ri(j);
pow_pos(ri(j),2)<=yi(j);
% norm([2
ri(j);yi(j)-1],2) <=yi(j)+1;
end
% sqrt(4
(pow_pos(ri,2))+pow_pos((yi-1),2))<=yi+1;
% sqrt(4*(ri.^2)+(yi-1).^2)<=yi+1;

``````        norm([2*X1;y-1],2)<=y+1;
norm([2*ri;yi-1],2)<=yi+1;
cvx_end
``````

Disciplined convex programming error:
Cannot perform the operation norm( {mixed convex/affine}, 2 )

norm([2*ri;yi-1],2)<=yi+1;

Hello, do you have a solution?

`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…

``````        for j=1:n
yi(j)=y-2*Anchors(j,1:2)*X1+Anchors(j,1:2)*(Anchors(j,1:2))';
``````

% ri(j)=norm(Anchors(j,1:2)-X1’);
ri_no_norm(j)=Anchors(j,1:2)-X1’;
h(j)=(bi(j)^2)yi(j)-2bi(j)ri(j);
% pow_pos(ri(j),2)<=yi(j);
% norm([2
ri(j);yi(j)-1],2) <=yi(j)+1;
end
% sqrt(4*(ri.^2)+(yi-1).^2)<=yi+1;
norm([2X1;y-1],2)<=y+1;
norm([2
ri_no_norm;yi-1],2)<=yi+1;
% sqrt(4*(pow_pos(ri,2))+pow_pos((yi-1),2))<=yi+1;
cvx_end

wrong usage cvx/subsasgn (line 39)
The assignment cannot be performed because the index on the left is not compatible with the size on the right.

ri_no_norm(j)=Anchors(j,1:2)-X1’;

Hello, thank you for your reply. I corrected this kind of error, I don’t know if it was corrected.

We donn’t know what function you want to express. Can you explain what you want to do, or show us your mathematical formulas? I guess what Dr.Stone were trying to say is `ri_no_norm(j) >= norm(Anchors(j,1:2)-X1');` rather than `ri_no_norm(j)=Anchors(j,1:2)-X1';`.

I think this will work:

``````expression ri_no_norm(2*n,1)
for j=1:n
ri_no_norm(2*j-1:2*j) = Anchors(j,1:2)'-X1;
end
``````

You should be able to vectgorize this (reformulate it to not use for loop) if executing this for loop takes too long for you.

And the point of the reformulation to not use norm of norm is that the expression using norm with ri_no_norm` is mathematically equivalent to the norm of norm formulation, but it is accepted by CVX.