clear
close all
clc
rng(1)
fc = 2.5;%in GHz, 载波频率2.5GHz
lambdac = 0.12;% 载波波长
B = 10*1e6;%带宽10MHz
No = -174;%白噪声功率密度 -174dBm/Hz
noise = -174 + 10*log10(B);%in dBm
Pn = 10^(noise/10)*1e-3;%in W
power = 46;%基站发送总功率, 46dBm
Pt = 10^(46/10)*1e-3; %in W
Nt = 512;%发送天线数
daltat = 0.5; %归一化发送天线间隔
Nr = 8;%接收天线数
lT = 200;% 8节车体总长度
dl= 200/8;%相邻天线间距
deltar = dl/lambdac;%归一化接收天线间隔 lambdac为载波波长
dmin = 30;%
%距离变化范围
drange = dmin:20:1e3;%从30变化到1000;
Ld = length(drange);%从30变化到1000;以20为间隔的点数个数
%生成信道数
Nch = 1e2; %100个
%可达速率
C_single = zeros(Ld,Nch);%每个场景值
C_dual = zeros(Ld,Nch);
C_eight = zeros(Ld,Nch);
%C_mimo = zeros(Ld,Nch);
%C_prop = zeros(Ld,Nch);
%proposed 方案激活天线数
NumAntenna = zeros(Ld,Nch);
for di = 1:1:Ld
d = drange(di); %第1根接收天线到发送天线距离
s = sqrt(d^2 - dmin^2);
D = zeros(Nr,1);
Cosine = zeros(Nr,1);
f = zeros(Nt,Nr);%导向向量
h = zeros(Nt,Nr);
for nr = 1:1:Nr
s1 = s - (nr-1)*dl;
D(nr) = sqrt(s1^2+dmin^2);
Cosine(nr) = s1/D(nr);
f(:,nr) = AntennaArrayResponseULA(Cosine(nr),Nt,daltat); % 第nr接收天线的导向向量
end
w = 1/sqrt(Nt)*f;%波束赋形权重
lambda = zeros(Nr,1);
for nr = 1:1:Nr
lambda(nr,1) = 1/(w(:,nr)'*w(:,nr));
end
%path loss, shadowing fading
Beta = 22.7*log10(D) + 41 + 20*log10(fc/5) + 4;% in dB
beta = 10.^(Beta/10);
for nch = 1:1:Nch
alpha = randn(Nr,1);
for nr = 1:1:Nr
h(:,nr) = f(:,nr)*alpha(nr,1).*exp(1i*D(nr,1)/lambdac); %小尺度衰落
end
%%{
%% 不同接收天线数
% pi 功率分配
% Po 有用信号功率
% Pi 干扰信号功率
% sinr 信号干扰噪声比
%% 激活第Nr根天线
pi = Pt; %
Po = pi/beta(Nr)*(norm(h(:,Nr)'*w(:,Nr),2)^2);
sinr = Po/Pn;
C_single(di,nch) = B*sum(log2(1+sinr));%总速率 bits/s
%% 激活首位两根天线
u = (Pt + 1./lambda(1)+1/lambda(Nr))/2;
pi = zeros(Nr,1);
pi(1) = u*lambda(1)-1;
pi(Nr)= u*lambda(Nr)-1;
sinr = zeros(Nr,1);
for nr = 1:1:Nr
Po = pi(nr)/beta(nr)*(norm(h(:,nr)'*w(:,nr),2)^2);
Pi = 0;
for i = 1:1:Nr
if i ~= nr
Pi = Pi + pi(i)/beta(i)*(norm(h(:,nr)'*w(:,i),2)^2);
end
end
sinr(nr) = Po/(Pi+Pn);
end
C_dual(di,nch) = B*sum(log2(1+sinr));%总速率 bits/s
%% 8接收天线全部激活
%注水算法功率分配
u = (Pt + sum(1./lambda))/Nr;
pi = u*lambda-1;%
% SINR 计算
sinr = zeros(Nr,1);
for nr = 1:1:Nr
Po = pi(nr)/beta(nr)*(norm(h(:,nr)'*w(:,nr),2)^2);
Pi = 0;
for i = 1:1:Nr
if i ~= nr
Pi = Pi + pi(i)/beta(i)*(norm(h(:,nr)'*w(:,i),2)^2);
end
end
sinr(nr) = Po/(Pi+Pn);
end
C_eight(di,nch) = B*sum(log2(1+sinr));%总速率 bits/s
% %% conventional Massvie MIMO
% sinr = zeros(Nr,1);
% for nr = 1:1:Nr
% sinr(nr) = Pt*beta(nr)*h(:,nr)'*h(:,nr)/(Nt*Pn);
% end
% C_mimo(di,nch) = real(B*sum(log2(1+sinr)));%总速率 bits/s
% %}
%%%%%%%%%%%%%%%%按照分组调整
Sopt=8;
ni=(Nt/Sopt)*ones(Sopt,1);
min_count=ones(Sopt,1);max_count=(Nt/Sopt)*ones(Sopt,1);
Cold=0;Cnew=1;
while(Cnew>Cold)
[Cold sinrold]=C_sinr_calculate(Sopt,ni,Pt,Nr,Nt);
mid_count=zeros(Sopt,1);
for ii=1:Sopt
while(max_count-min_count>1)
mid_count(ii,1)=floor((min_count(ii,1)+ max_count(ii,1))/2);
[Cnew1 sinrnew1]=C_sinr_calculate(Sopt,mid_count,Pt,Nr,Nt);
[Cnew2 sinrnew2]=C_sinr_calculate(Sopt,mid_count+ones(Sopt,1),Pt,Nr,Nt);
if(Cnew1>Cnew2)
max_count=mid_count;
else if(Cnew1<Cnew2)
min_count=mid_count+ones(Sopt,1);
else break;
end
end
if((max_count-min_count)==1)
[Cnew0 sinrnew0]=C_sinr_calculate(Sopt,min_count,Pt,Nr,Nt);
[Cnew3 sinrnew3]=C_sinr_calculate(Sopt,max_count,Pt,Nr,Nt);
if(Cnew0>Cnew3)
ni=min_count;
else if(Cnew0<Cnew3)
ni=max_count;
end
end
else ni=mid_count;
end
[Cnew SINRnew]=C_sinr_calculate(Sopt,ni,Pt,Nr,Nt);
end
end
ni=Nt/Sopt;
[Cnew00 sinrnew00]=C_sinr_calculate(Sopt-1,ni,Pt,Nr,Nt);
if(Cnew00>Cold)
Sopt=Sopt-1;
ni=Nt/Sopt;
end
end
end
end
C_single_average = mean(C_single,2);
C_dual_average = mean(C_dual,2);
C_eight_average = mean(C_eight,2);
%C_mimo_average = mean(C_mimo,2);
%C_prop_average = mean(C_prop,2);
%NumAntenna_average = mean(NumAntenna,2);
%%{
figure(1)
semilogy(drange,C_single_average,'-*r',drange,C_dual_average,'-^g',drange,C_eight_average,'-ob')
xlabel('d(m)');
ylabel('Throughput(bps)')
legend('Single-stream BF','Dual-stream BF','Eight-stream BF')
%}
figure(2)
plot(drange,NumAntenna,'o-r')
xlabel('d(m)');
ylabel('number of selected beams')
评论3