Try starting a fresh MATLAB session. Perhaps there is a conflict due to having previously used the original CVX version of exponential.m in the same session in which you later try to use the CVXQUAD version.

Please be sure you are using CVX 2.1, not CVX3.0beta. Deinstall 3.0beta and install CVX2.1 if necessary.

The statement e=(zeta*sum(pwr))+Pc-eta*sum(pwr)*(sum(g*(1-alph)));
has a product between the variables pwr and alph. That is a non-convex formulation. Have you proven the overall model is convex? if so, how.

I will mark this question as non-convex until such time you show otherwise.

which portion is non-convex in this part of expression ‘e’. There is no direct product of pwr and alph, as you said. Product is between sum(pwr) and sum(g*(1-alph))

That product may not be “direct” per your definition, but it is a product (there are product terms). Consider the case of dimension 1 and g = 1; then there is a product pwr*(1-alph), which has the product term -pwr*alph. Things don;t get any better with dimension > 1, unless g = 0.

I have changed this portion of the code -
d=B*(-rel_entr(1,(1+(gpwr/(sigma^2)+gspow))));
expression e=(zetasum(pwr))+Pc-etasum(pwr)(sum(g(1-alph)));
maximize d-q(i)*e;

Now I am getting the following error-

Error using expression (line 39)
Invalid variable specification: e=(zetasum(pwr))+Pc-etasum(pwr)(sum(g(1-alph)))

Error in swipt1 (line 31)
expression e=(zetasum(pwr))+Pc-etasum(pwr)(sum(g(1-alph)));
How to deal with that ?

An expression declaration and assignment e = .... must be in separate statements (i.e., you have made a syntax error). In this case, you don’t need expression at all, so change the statement to e=(zeta*sum(pwr))+Pc-eta*sum(pwr)*(sum(g*(1-alph)));
and at least you shouldn’t get that error message.

I am not getting anything. To solve the DCP Error only, I have used the keyword ‘expression’. I have got the idea from Section 4.8 ‘Assignment and expression holders’ in the CVX Manual. And now you are telling that keyword expression is not needed at all.

Your original expression is non-convex. Playing around with expreession keyword doesn’t solve that., but could hie it if you encounter another error first.