How to solve {convex} .* {convex}

how to let cvx receive (norm(x) )^2
like this
image
and my code is here

global N_0
global sum_gr
global h_k_e
global b_kn
global a_kn
global h_u_b
global K
global N
global D_k
global K
global N
global B
global eve_position_chushi_1
for k = 1:K
for n = 1:N
A_n(k,n) = Db2Dec(-60).*0.5/(b_kn(k,n)N_0B);
B_n(k,n) = Db2Dec(-60).*0.5;
C_n(k,n) = Db2Dec(-60).0.5sum_gr(1,1,n);
D_n(k,n) = (abs(h_k_e(k,n))^2).*0.5;
E_n(k,n) = B.*b_kn(k,n)*N_0+sum_gr(1,1,n);
end
end

q_0 = zeros(1,2,N);
for j = 1:3

cvx_begin

    variable   q(1,2,1);
    variable T(1,1);
    variable U(1,1);
    variable Z(1,1);
    expression q_0(1,2,1);
    expression r(1,1);
    expression cs(1,1);

             cs(1,1)=100*100+(norm(q(1,2,1)-eve_position_chushi_1(1,2,1))).*(norm(q(1,2,1)-eve_position_chushi_1(1,2,1)));

            r(1,1)=-log(1./(D_n(1,1)+E_n(1,1)) - (B_n(1,1)+C_n(1,1)).*inv_pos((B_n(1,1)).*(B_n(1,1).*Z(1,1)+(D_n(1,1)+E_n(1,1))) ) )./log(2);

    
    minimize(r)

        subject to
        U>0;
        U<100;

    cvx_end
    q_0 = q;

end

错误使用 .* (第 173 行)
Disciplined convex programming error:
Cannot perform the operation: {convex} .* {convex}

出错 trajectory123 (第 41 行)
cs(1,1)=100100+(norm(q(1,2,1)-eve_position_chushi_1(1,2,1))).(norm(q(1,2,1)-eve_position_chushi_1(1,2,1)));

Use square_pos(norm(...)) instead of norm(...)^2

This and many more functions are listed in the CVX Users Guide. For many functions the online help is more detailed information than the CVX Users; Guide, for instance concerning requirements for the function argument(s).

2 Likes

Thanks Mark I solve it