% Input data
k= 10;%用户数
n = k/2; %子信道数
D=5000;%小区半径
LT=2;
zong=0;
cong=0;
rmin=20000;%速率最小值
B=25000;%总范围 lte 223—235Mhz
N0=(10^(-17.4))/1000;%噪声密度
Pmax=6;
data0 = 50+(D/2-50)*rand(1,n);%随机产生distance 前五个距离小,后五个距离大
data1=D/2+(D-D/2)*rand(1,n);
distance=[data0,data1];
h = -96.97047 - 29.8283 * log10(distance / 1000);%单位是dB#Okumura-Hata模型算的
newh=power(10 , (h / 10));
hgain0=sort(newh);
P0 = 10^(Pmax / 10) / 1000 / n;%给每个子信道平均分配功率
hgain=[hgain0;hgain0;hgain0;hgain0;hgain0]’;%增益矩阵
P=P0+zeros(k,n);%功率矩阵cvx_begin gp
variable q(k,n)expression y(k,n);
for m=1:k
for N=1:n
%连乘
A=0;for i=1:m-1 a=q(i,N)*P(i,N); A=A+a; end C=hgain(m,N)*A+N0*B;%优化公式的上半部分 D=1; psum=0; for i=1:m psum=psum+P(i,N); end for i=1:m d=power(hgain(m,N)*q(i,N)* psum,P(i,N)/ psum); D=D*d; end y(m,N)=C/D; end
end
%F=prod();
% y=rate(P,q,hgain,k,n,N0,B);
minimize(prod(y))
subject to
for carries=1:n
for m=1:k
zong=zong+q(m,carries)*P(m,carries);
cong=cong+q(m,carries);
end
cong<=LT;cong=0;
end
zong<=Pmax;
zeros(k,n)<=q <=ones(k,n);
cvx_end
Here is the beginning of the MATLAB help for prod
.
help prod
prod Product of elements.
P = prod(X) is the product of the elements of the vector X. If X is a
matrix, P is a row vector with the product over each column. For
N-D arrays, prod(X) operates on the first non-singleton dimension.
…
Therefore, your objective, prod(y),
is 1 by n
row vector, which is not a scalar. I will leave it to you how to fix this, because I don’t know what you want the objective to be.Of course, whatever fix you make will have to comply with CVX’s gp rules.