 # Conversion to double from cvx is not possible problem

Hello everyone, I have written a local function in matlab and called it in cvx (my function name is Re and called it in cvx and its arguments: p and p0 are vectors and N is scalar).
I’ve written my code below, my error is “Conversion to double from cvx is not possible” can you help me eliminate it?
Thank you.

cvx_begin

variable x(n);
minimize (norm(p-Re(p,p0+x,N)));
subject to
x(1) == 0.5;
x(2) == 0.5;
0 < x(3)^2+x(4)^2 <=1;
0 < x(5)^2+x(6)^2 <=1;
0 < x(7)^2+x(8)^2 <=1;
0 < x(9)^2+x(10)^2 <=1;

cvx_end

You can also see some of my other related answers if you search this forum for:
`conversion to double from cvx is not possible`

But unfortunately I’ve encountered this error again.
I wrote a function in matlab and called it in this code and when optimization’s variable means x(n) becomes input argument of mu function “Re()” I get this error again.
According your tips I define a expression and define it but anything didn’t change.
My new cod is below:

``````cvx_begin
variable x(n);
expression w(n)
for i=1:n
w(i)= p0(i)+x(i);
end
Q = norm(p-(Re(p,w,Na)));
minimize (Q)
expression z(4);
z(1)=x(3)^2+x(4)^2;
z(2)=x(5)^2+x(6)^2;
z(3)=x(7)^2+x(8)^2;
z(4)=x(9)^2+x(10)^2;
subject to
x(1) == 0.5;
x(2) == 0.5;
z(1) <= 1;
z(2) <= 1;
z(3) <= 1;
z(4) <= 1;

cvx_end
``````

Sincerely.

You’ll have to show us the code for your function `Re`