There are my codes:
o=1;
Omax=5;
elta3(o)=0.1;
tempRate=zeros(48,Omax);
f=zeros(Omax);
M3=zeros(Omax);
while 1
cvx_begin
variable p_opt3(48,Omax)
expression tempRate(48,Omax)
% expression f3(48,Omax)
% expression M(Omax)
% calculate f3
for k=1:K %12
for wn=1:WN % WN=2
for n=1:N % N=2
pkn=sum(p_opt3((k-1)*N+1:(k-1)*N+n,o));
end
tempRate((k-1)*WN+wn,o)=log(alpha*(H^2+re33((k-1)*WN+wn,1))+pkn)/log(2);
% f3((k-1)*WN+wn,o)=sum(tempRate(1:(k-1)*WN+wn,o));
end
end
f3(o)=sum(tempRate(:,o));
M3(o)=f3(o)-elta3(o);
cvx_end
o=o+1;
[M3(o),~,~]=calcMaxVal_group3(K,N,L,WN,p3,H,re33,v,c1,c2,alpha);
if abs(M3(o)-M3(o-1))<delta && o<Omax
break;
else
end
I don’t know why the f3 can’t be assigned to M3. The wrong is " Using double incorrectly. Cannot convert from cvx to double".
And when I call/invoke this file from another file (the contents are similar, include statements and parameters), it displays “tempRate((k-1)WN+wn,o)=log(alpha(H^2+re33((k-1)*WN+wn,1))+pkn)/log(2);” is wrong.The wrong is " Index out of matrix dimension". But I run this file alone, it is right.
Here are another files’ codes:
v2(:,o)=[0.1Vmax;0.5Vmax];
tempRate=zeros(48,Omax);
pSolution2=zeros(2U,Omax); %功率值
[pSolution2(:,o)]=getgroup2_p();
re22=zeros(2U,1);
[~,re22(:,1),~]= get_group();
while 1
cvx_begin
variable v_opt2(L);
expression tempRate(2U,Omax)
expression f2(2U,Omax)
% cla f2
for k=1:K
for wn=1:WN
for n=1:N
pkn=sum(pSolution2((k-1)*N+1:(l-1)*K*N+(k-1)*N+n));
end
tempRate((k-1)*WN+wn,o)=log(alpha*(H^2+re22((k-1)*WN+wn))+pkn)/log(2);
f2((k-1)*WN+wn,o)=sum(tempRate(1:(k-1)*WN+wn,o));
end
end
end