% SNR_dB=160;%SNR(dB)
% SNR_linear=10.^(SNR_dB/10);
f=(2959*10^6);
lamda=(3*10^8)/(2959*10^6);%波長
hB=32;
hm=1.5;
d2=3;
CH=0;
Gt=30;%(dBm)
n=-110;%(dBm)
PL=69.55+26.16*log10(f)-13.82*log10(hB)-CH+(44.9-6.55*log10(hB))*log10(d2)-(3.2*(log(11.75*hm)^2-4.97));
sf=1;%Shadow fading variance;
N_iter=10000;%蒙地卡羅迴圈執行次數
c=jet(6);
path=60;%路徑數
d=0.5*lamda;%天線間距離(m)
Nt=1;%Tx個數
Nr=1;%Rx個數
for Icase=1:6
if Icase==1,theta_tilt=0;
elseif Icase==2,theta_tilt=45*pi/180;
elseif Icase==3,theta_tilt=90*pi/180;
elseif Icase==4,theta_tilt=100*pi/180;
elseif Icase==5,theta_tilt=135*pi/180;
elseif Icase==6,theta_tilt=180*pi/180;
end
n=min(Nt,Nr);
I=eye(n);
for iter=1:N_iter
azimuth_tx=[];
azimuth_rx=[];
elevation_tx=[];
elevation_rx=[];
at=[];
gt=[];
B=[];
%% 傳輸端天線方位角度
for azimuth_cont_tx=1:Nt*path
azimuth_tx=[azimuth_tx 0];
end
azimuth_tx=reshape(azimuth_tx,[Nt path]);
%% 傳輸端天線傾角度
for elevation_cont_tx=1:Nt*path
elevation_tx=[elevation_tx theta_tilt+10*pi/180];
end
elevation_tx=reshape(elevation_tx,[Nt path]);
%% 接收端天線方位角度
for azimuth_cont_rx=1:Nr*path
azimuth_rx=[azimuth_rx 0];
end
azimuth_rx=reshape(azimuth_rx,[Nr path]);
%% 接收端天線仰角度
for elevation_cont_rx=1:Nr*path
elevation_rx=[elevation_rx 10*pi/180];
end
elevation_rx=reshape(elevation_rx,[Nr path]);
%% 設定at參數
for at_cont=1:Nt*path
at=[at exp(j*(2*pi/lamda)*(ceil(at_cont/path)-1)*d*sin(azimuth_tx(at_cont))*sin(elevation_tx(at_cont)))];
end
at=(reshape(at,[path Nt]))';
%% 設定gt(gain)參數
for gt_cont=1:Nt*path
gt=[gt sqrt(10^((-12*(azimuth_tx(gt_cont)/(7*pi/18))^2)/10)*10^((-12*((elevation_tx(gt_cont)-theta_tilt)/(pi/12))^2)/10))];
end
gt=conj((reshape(gt,[path Nt]))');
%% A=at*gt
A=sqrt(1/path)*at.*gt;
%% B
for B_cont=1:Nr*path
B=[B exp(j*(2*pi/lamda)*(ceil(B_cont/path)-1)*d*sin(azimuth_rx(B_cont))*sin(elevation_rx(B_cont)))];
end
B=conj((reshape(B,[path Nr]))');
%% 隨機振幅(複數,Gaussian distribution,N(0,1/path))
alpha=sqrt(0.5)*(randn(path,1)+j*randn(path,1));
diag_matrix=diag(alpha);
%%
H=sqrt(10.^(-1*(PL+sf-Gt)))*sqrt(1/path)*B*diag_matrix*A';
if Nr>=Nt,HH=H'*H;
else HH=H*H';
end
SNR_dB=(Gt-sf-PL)-n;
SNR_linear=10.^(SNR_dBm/10.^-3);
C(iter)=log2(real(det(I+SNR_linear/Nt*HH)));
end
[PDF,Rate]=hist(C,500);
PDF=PDF/N_iter;
for i=1:500
CDF(Icase,i)=sum(PDF([1:i]));
end
plot(Rate,CDF(Icase,:),'Color',c(Icase,:),'LineWidth',1.0);hold on
end
xlabel('Rate[bps/Hz]');ylabel('CDF');
axis([-inf,inf,0,1]);grid on;set(gca,'fontsize',10);
legend('downtilt=0\circ','downtilt=45\circ','downtilt=90\circ','downtilt=100\circ','downtilt=135\circ','downtilt=180\circ');
% ,'downtilt=60\circ','downtilt=70\circ','downtilt=80\circ','downtilt=90\circ','downtilt=100\circ','downtilt=110\circ','downtilt=120\circ','downtilt=130\circ','downtilt=140\circ','downtilt=150\circ','downtilt=160\circ','downtilt=170\circ','downtilt=180\circ');