# CVX error: "Disciplined convex programming error: Invalid quadratic form(s): not a square."

Error using .* (line 262)
Disciplined convex programming error:
Invalid quadratic form(s): not a square.

Error in * (line 36)
z = feval( oper, x, y );

Error in final_project2 (line 92)
((-x_n(1)^2+2x_n(1)x(1))(2/s_n(1)-s(1)/(s_n(1)^2)))-(2real((w’A_13w_n)/(q_n(3)))-((w_n’A_13w_n)/(q_n(3)^2)*q(3)))<=0;

how can i fix this error?

You haven’t told us which variables are CVX variables as opposed to MATLAB variables, nor the values of the MATLAB variables. Have you proven that the left-hand-side is convex?

here is the CVX part of my code:

cvx_begin
variables q(N) w(NN) s(N) x(N) u(N) t0(1)
maximize(sum(log(u)/log(2)))
subject to
t0>0;
for i=1:N
u(i)-1-2./s_n+s./(s_n.^2)<=0;
u(i)>0;
end
((-x_n(1)^2+2
x_n(1)x(1))(2/s_n(1)-s(1)/(s_n(1)^2)))-(2real((w’A_13w_n)/(q_n(3)))-((w_n’A_13w_n)/(q_n(3)^2)q(3)))<=0;
((-x_n(2)^2+2
x_n(2)x(2))(2/s_n(2)-s(2)/(s_n(2)^2)))-(2
real((w’A_24w_n)/(q_n(4)))-((w_n’A_24w_n)/(q_n(4)^2)q(4)))<=0;
((-x_n(3)^2+2
x_n(3)x(3))(2/s_n(3)-s(3)/(s_n(3)^2)))-(2real((w’A_31w_n)/(q_n(1)))-((w_n’A_31w_n)/(q_n(1)^2)q(1)))<=0;
((-x_n(4)^2+2
x_n(4)x(4))(2/s_n(4)-s(4)/(s_n(4)^2)))-(2
real((w’A_42w_n)/(q_n(2)))-((w_n’A_42w_n)/(q_n(2)^2)q(2)))<=0;
((w’A_12w)/(q(2)))+((w’A_14w)/(q(4)))+sigma^2
(w’B_1w)+sigma^2-(-x_n(1)^2+2x_n(1)x(1))<=0;
((w’A_21w)/(q(1)))+((w’A_23w)/(q(3)))+sigma^2
(w’B_2w)+sigma^2-(-x_n(2)^2+2
x_n(2)x(2))<=0;
((w’A_32w)/(q(2)))+((w’A_34w)/(q(4)))+sigma^2
(w’B_3w)+sigma^2-(-x_n(3)^2+2x_n(3)x(3))<=0;
((w’A_41w)/(q(1)))+((w’A_43w)/(q(3)))+sigma^2
(w’B_4w)+sigma^2-(-x_n(4)^2+2
x_n(4)x(4))<=0;
es
sum(1/q)+er*((w’D_1w)/(q(1))+(w’D_2w)/(q(2))+(w’D_3w)/(q(3))+(w’D_4w)/(q(4))+sigma^2*w’w)+Pcir-(2/t0_n-t0/t0_n^2)<=0;
for i=1:N
s(i)>0;
q(i)>=1/P(e);
end
(abs(g_11)^2/q(1)+abs(g_21)^2/q(2)+abs(g_31)^2/q(3)+abs(g_41)^2/q(4))<=I;
((w’D_1w)/q(1)+(w’D_2w)/q(2)+(w’D_3w)/q(3)+(w’D_4w)/q(4)+sigma^2
w’w)<=P(e);
((w’C_11w)/q(1)+(w’C_21w)/q(2)+(w’C_31w)/q(3)+(w’C_41w)/q(4)+sigma^2
w’E_1w)<=I;
cvx_end

becauce the optimisation problem is from a paper, so i think it’s convex.