# Unable to have an assignment because value of type 'cvx' is not convertible to 'double'

Here is my code

cvx_begin
variable W(N,I) complex
variable u(I,1)
variable y
variable t(I,1)
variable m(I,1)
variable v(I,1)

``````    expression V1(I,1)
expression V2(I,1)
expression V3(I,1)

V1 = zeros(I,1);
V2 = zeros(I,1);
V3 = zeros(I,1);
for i=1:I
hi = h(:,i);
for l=1:I
if(l~=i)
V1(i) = V1(i) + real(W(:,l)'*conj(hi)*hi.'*W(:,l));
V2(i) = V2(i) + 2*sqrt(m_hat(i)*v_hat(l))*sqrt(m(i)*v(l));
V3(i) = V3(i) + m_hat(i)*v_hat(l)/(1 + m_hat(i)*v_hat(l))*(m(i)^2+v(l)^2)/2;
end
end
``````

Matlab says "Unable to perform assignment because value of type ‘cvx’ is not convertible to ‘double’ ". The error is at this line “V1(i) = V1(i) + real(W(:,l)‘*conj(hi)*hi.’*W(:,l));” and h is a given complex variable matrix.

I have already use expression to store V1, V2 and V3, so i don’t know why it has this error.

Remove

``````V1 = zeros(I,1);
V2 = zeros(I,1);
V3 = zeros(I,1);
``````

Those statements override the earlier expression declarations. Hence the error message. Note that every element of an expression is automatically initialized to zero by CVX.

wow, it really works, thanks bro!!