Output Coming Nan

This is my code and i am getting Nan output>…!!!
cvx_begin
cvx_solver sedumi

variable W(2n,2n) symmetric
variables f_obj(n,1) u(npv,1)

for i=1:n
f_obj(i,1)==trace(YYreal(:,:,i)W);
end
minimize (1
(sum(u)+trace(YYreal(:,:,n)*W)))

subject to

for i=1:npq
trace(YYreal(:,:,i)*W)-(Pg(i,1)-Pl(i,1))==10^-7;
trace(YYimag(:,:,i)*W)-(Qg(i,1)-Ql(i,1))==10^-7;
end
for i=1:npv
trace(YYreal(:,:,i+npq)*W)-(u(i,1)-Pl(i+npq,1))==10^-7;
end
trace(YYreal(:,:,n)*W)+Pl(n,1)>=0

sum(u)>=0

W==semidefinite(2*n);
W>=0;
cvx_end

Please show the solver and CVX output. Perhaps the problem is infeasible? if so, follow the advice at https://yalmip.github.io/debugginginfeasible/ , which applies to CVX, except for section 1.

The constraints trace(…) == 10^-7 look rather suspicious. You could consider replacing them inequalities to see whether that produces feasibility.

You are constraining W to be psd and elementwise nonnegative. Is that what you intend? That may be fine if that’s what you want.

Also check the problem scaling (input data).

Yes i want my constraint W to be semidefinite.

Do you also want all its elements to be nonnegative?