{concave} - {concave}

Error:

Disciplined convex programming error: Illegal operation: {concave} - {concave}

Code:
[M1(I1),g1(I1)]=calcMaxVal_group1(K,N,L,WN,p1(:,I1),elta1(o),H,re11,v,c1,c2,alpha);
while 1
[g1_diff]=g1_firstorderdiff(K,N,L,WN,p1(:,I1),alpha,H,re11);
cvx_begin
variable p_opt1(2*U)
expression tempRate1 %求f
expression tempRate_g1 %求g
expression f1
expression E1
expression M1

``````          % 计算f1和g1
for l=1:L % 2
for k=1:K  %12 组
for wn=1:WN %2
for n=1:N  % 2
pkn1=sum(p_opt1((l-1)*K*N+(k-1)*N+1:(l-1)*K*N+(k-1)*N+n));
if n+1<=N
for nv=n+1:N
pkn_gp1=sum(p_opt1((l-1)*K*N+(k-1)*N+(n+1):(l-1)*K*N+(k-1)*N+nv));
end
end
end
tempRate1=tempRate1+log(alpha*(H^2+re11((l-1)*K*WN+(k-1)*WN+wn))+pkn1)/log(2);
tempRate_g1=tempRate_g1+log(alpha*(H^2+re11((l-1)*K*WN+(k-1)*WN+wn))+pkn_gp1)/log(2);
end
end
E1=E1+c1*pow_pos(norm(v(l)),3)+c2*inv_pos(v(l,1));
end
f1=tempRate1-elta1(o)*E1;
g1=tempRate_g1+g1_diff*(p_opt1-p1(:,I1));
M1=f1-g1;
``````

`f1` and `g1` are both concave. Hence the error message for `{concave} - {concave}`, which is not allowed by CVX"s DCP rules.

I don’t know what you intend to do with `Mq`, so perhaps there is a way of writing the code which does not require forming `M1`.