# When i solve this problem using cvx, Disciplined convex programming error?

``````clc,clear;
close all;

N = 10;
M=2;
H_AI = rand(N,N)+1i*rand(N,N);
H_IW = rand(M,N)+1i*rand(M,N);

w = rand(N,1)+1i*rand(N,1);
W = w*w';
W= (W+W')/2;
P=0.1;
cvx_begin
variable phi(N,1) complex
minimize (real(rand(N,1)'*phi))
subject to
real(trace(H_IW*diag(phi)*H_AI*(w*w')*H_AI'*diag(phi)'*H_IW'))<=1
% norm([2*H_IW*diag(phi)*H_AI*w;1-P])<=1+P;
cvx_end
``````

The error is because you are multiplying a matrix variable by another matrix variable, namely `diag(phi)`. That is a non-scalar quadratic form, which is non-convex, or at least not determinable by CVX to be convex.

The LHS of the inequality constraint can rewritten as:
`trace((H_aw+H_iw*diag(phi)*H_ai)*(w*w'+mu*diag(w*w'))*(H_aw+H_iw*diag(phi)*H_ai)') = trace((H_aw+H_iw*diag(phi)*H_ai)*sqrtm(w*w'+mu*diag(w*w'))*sqrtm(w*w'+mu*diag(w*w'))*(H_aw+H_iw*diag(phi)*H_ai)') = trace((sqrtm(w*w'+mu*diag(w*w'))*(H_aw+H_iw*diag(phi)*H_ai)')'*(sqrtm(w*w'+mu*diag(w*w'))*(H_aw+H_iw*diag(phi)*H_ai)')) = norm(sqrtm(w*w'+mu*diag(w*w'))*(H_aw+H_iw*diag(phi)*H_ai)','fro')^2`

Therefore, use
`norm(sqrtm(w*w'+mu*diag(w*w'))*(H_aw+H_iw*diag(phi)*H_ai)','fro') <= sqrt(eta)`

`Note that sqrtm(w*w'+mu*diag(w*w'))` is a real symmetric matrix because `w*w'+mu*diag(w*w')` is psd.

ok,i have got it, thank you very much.