How can I solve this problem:" Disciplined convex programming error: Illegal operation: exp( {affine} )"

Hello,CVX community,
I’m trying to solve the problem with cvx in the following:

cvx_begin
variables r
variables e
expression r0
expression F(q)
expression F1(q+1)
expression temp(q)
minimize e
for n1=1:1:N
    for n2=1:1:N
        F(q,:)=exp(j*kc*(R*r0*cos(thetak)*cos(phi_m-thetak))/rk+(xn(:,n1)-xn(:,n2))*cos(thetak)+((xn(:,n1))^2-(xn(:,n2))^2)*(sin(thetak))^2/2/rk; 
        F1(q+1,:)=1+j*kc*r*(xn(:,n1)-xn(:,n2))*cos(thetak)*cos(phi_m-thetak)/rk;
        temp(q,:)=temp(q,:)+F(q,:)*F1(q+1,:);
    end
end
subject to
    abs(temp(q,:))<=e;
    0<(r0+r)<1
    abs(r)<=r_max;
cvx_end

But the first expression in the loop,” F(q,:)”,got this error” Disciplined convex programming error:Illegal operation: exp( {affine} ).”
How can I fix it? Any help from your guys would be appreciated.

I don’t see how that error occurred. i don’t see anything in the argument of exp which is a CVX variable or expression. Am I missing something? And I have no idea why exp(affine) would be illegal if the argument of exp were in fact affine, which it doesn’t appear to be.

There’s a similar line of code in another program that works fine, so I don’t quite understand how this error happened. Mark, do you have any suggestions to help me?Thank you very much!

Are you using CVX 3.0beta? If so, remoce all CVX directories from the MATLAB path and install CVX 2.2

cvx_version shows what version is installed.

Or try new MATLAB session, or reinstalling CVX 2.2.

I’m using CVX 2.2. And I also try new MATLAB session. Maybe I’ll have to reinstall CVX 2.2. Thanks for your suggestion.