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.

Thank you so much for your attention. I imposed your comments.
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: