⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 all.m

📁 本源代码给出了一个完整的蜂窝移动通信系统的仿真程序实例,开发环境是matlab,希望可以从事此方面工作的人员提供一个借鉴.
💻 M
字号:
% File: c17_cellularsetup.m
% Software given here is to accompany the textbook: W.H. Tranter, 
% K.S. Shanmugan, T.S. Rappaport, and K.S. Kosbar, Principles of 
% Communication Systems Simulation with Wireless Applications, 
% Prentice Hall PTR, 2004.
%
% ===== Pre-defined parameters =========================================
r_cell = 1000;		% cell radius (in meters)
n_co_ch_users = 6;	% number of co-channel users
P_BS = 0;			% BS transmitter power (in dBW)
P_MS = 0;			% MS transmitter power (in dBW)
corr_fwd = 0.0;		% correlation coefficient - forward link
corr_rev = 0.0;		% correlation coefficient - reverse link
K = 1;			    % constant in the link equation
in_beam = 0;		% maximum gain of the sectorized antennas (in dB)
% --- Limits (angles) of each sector ---
sector_min = zeros(6,3);
sector_max = zeros(6,3);
sector_min(:,1) = (pi/3)*[-3:2]';
sector_min([1:3],2) = pi/3*[-3 -1 1]';
sector_min(1,3) = -pi;
sector_max(:,1) = sector_min(:,1) + pi/3;
sector_max([1:3],2) = sector_min([1:3],2) + 2*pi/3;
sector_max(1,3) = pi;
%
% --- Center of each sector ----
%
phi_center = zeros(6,3);
phi_center(:,1) = (pi/3)*[-3:2]';
phi_center([1:3],2) = (pi/3)*[-3 -1 1]';
%
% --- Beamwidth of each sector ---
%
phi_BW = [1 2 6]*pi/3;
%
% --- Number of sectors ----- 
%
num_sectors = [6 3 1];
%
% ===== User Inputs =========================================
%
num_snapshots = input('Number of snapshots = '); 
cluster_size = input('Cluster size (3, 4 or 7) = ');
n_path = input('Path loss exponent = ');
sigma_int = input('Shadowing std deviation - interference (dB) = ');
sigma_S = input('Shadowing std deviation - desired signal (dB) = ');
sec = input('Sectorization (1=>60-sectoring, 2=>120-sectoring, 3=>omni). enter ---> ');
ftb = input('Front-to-back ratio of the BS antennas (dB) = ');
out_beam = in_beam - ftb;
SIR_target_lower=input('the lower value of the target SIR_target (dB)= ');
SIR_target_upper=input('the upper value of the target SIR_target (dB)= ');
% End of script file.
    P_fwd_average_outage=zeros(41);
    P_rev_average_outage=zeros(41);
    P_fwd_outage_A=zeros(41);
    P_rev_outage_A=zeros(41);
    P_fwd_outage_B=zeros(41);
    P_rev_outage_B=zeros(41);
for SIR_target=SIR_target_lower:SIR_target_upper
    P_fwd_outage=0;
    P_rev_outage=0;
    Num_A_fwd=0;
    Num_A_rev=0;
    Num_B_fwd=0;
    Num_B_rev=0;
  for i=1:num_snapshots
%location of base stations (center cell is located at x=0,y=0)
%Location (angular) of the center cell of each cluster in the first tier
theta_N=[pi/6 0 pi/6 asin(1/(2*sqrt(7)))];
aux_1=[1 0 2 3 0 0 4];
theta=pi/3*[0:5]';
ind=aux_1(cluster_size);
%Location [x,y] of the center cells of all clusters in the first tier
bs_position=[sqrt(3*cluster_size)*r_cell*cos(theta+theta_N(ind)) sqrt(3*cluster_size)*r_cell*sin(theta+theta_N(ind))];
%Determination of the sector to simulated in this snapshot(˲̬ͼ)
%--------Select(randomly)a sector-------
sector=unidrnd(num_sectors(sec));
%---Place the desired mobile within the selected setor--
des_user_beta=rand(1)*phi_BW(sec)+phi_center(sector,sec);
des_user_r=sqrt(rand(1).*(r_cell^2));
%place co_channel mobiles within the selected sector of co-channel cells---
co_ch_user_beta=rand(6,1)*phi_BW(sec)+phi_center(sector,sec);
co_ch_user_r=sqrt(rand(6,1)*(r_cell^2));
%computer the positions of the co_channel mobiles and the target mobile
des_user_position=des_user_r.*[cos(des_user_beta) sin(des_user_beta)];
co_ch_user_position=[co_ch_user_r.*cos(co_ch_user_beta) co_ch_user_r.*sin(co_ch_user_beta)]+bs_position;
%------desired user----
m_S_fwd=P_BS-10*K*n_path*log10(des_user_r);
%-------co-channel user----
%-------Location of desired mobile with respect to co-channel cells----
aux_01=((des_user_position(1)-bs_position(:,1))+sqrt(-1)*(des_user_position(2)-bs_position(:,2)));
beta_fwd=angle(aux_01);
d_I_fwd=abs(aux_01);
%----Computation of antenna gain at co-channel cells
clear gain_fwd
for k=1:n_co_ch_users
    if (beta_fwd(k)>=sector_min(sector,sec))&&(beta_fwd(k)<sector_max(sector,sec))
        gain_fwd(k)=in_beam;
    else
        gain_fwd(k)=out_beam;
    end    
end
%---computation of mean value and standard devitation---
m_I_fwd=P_BS-10*K*n_path*log10(d_I_fwd)+gain_fwd.';
sigma_I_fwd=sigma_int*ones(length(m_I_fwd),1);
[m_I_total_fwd,sigma_I_total_fwd]=wilkinson(m_I_fwd,sigma_I_fwd,corr_fwd);
%------Desired user----
m_S_rev=P_MS-10*K*n_path*log10(des_user_r);
%-------co-channel user----
%-------Location of desired mobile with respect to co-channel cells----
aux_02=(co_ch_user_position(:,1)+sqrt(-1)*co_ch_user_position(:,2));
beta_rev=angle(aux_02);
d_I_rev=abs(aux_02);
%----Computation of antenna gain at co-channel cells
clear gain_rev
for k=1:n_co_ch_users
    if (beta_rev(k)>=sector_min(sector,sec))&&(beta_rev(k)<sector_max(sector,sec))
        gain_rev(k)=in_beam;
    else
        gain_rev(k)=out_beam;
    end    
end
%---computation of mean value and standard devitation---
m_I_rev=P_BS-10*K*n_path*log10(d_I_rev)+gain_rev.';
sigma_I_rev=sigma_int*ones(length(m_I_rev),1);
[m_I_total_rev,sigma_I_total_rev]=wilkinson(m_I_rev,sigma_I_rev,corr_rev);
%-----(Step 1)computation mean value and standard devitation of SIR----------
      m_SIR_fwd_1(i)=m_S_fwd-m_I_total_fwd;
      sigma_SIR_fwd_1(i)=sqrt(sigma_S^2+sigma_I_total_fwd^2-2*corr_fwd*sigma_S*sigma_I_total_fwd);
      m_SIR_rev_1(i)=m_S_rev-m_I_total_rev;
      sigma_SIR_rev_1(i)=sqrt(sigma_S^2+sigma_I_total_rev^2-2*corr_rev*sigma_S*sigma_I_total_rev);
      P_fwd_outage=P_fwd_outage+(1-0.5*erfc((SIR_target-m_SIR_fwd_1(i))/(sigma_SIR_fwd_1(i)*sqrt(2))));
      P_rev_outage=P_rev_outage+(1-0.5*erfc((SIR_target-m_SIR_rev_1(i))/(sigma_SIR_rev_1(i)*sqrt(2))));
%------------------(Step 2: Method A)sample over user's signal andinterference signal-------------------------
      SIR_fwd_2(i)=normrnd(m_SIR_fwd_1(i),sigma_SIR_fwd_1(i));
      SIR_rev_2(i)=normrnd(m_SIR_rev_1(i),sigma_SIR_rev_1(i));
   if SIR_fwd_2(i)<SIR_target
       Num_A_fwd=Num_A_fwd+1;
   end
   if SIR_rev_2(i)<SIR_target
      Num_A_rev=Num_A_rev+1;
   end
%------------------(Step 2:Method B)sample over user's signal and interference signal-------------------------
      des_sig_spl_fwd=normrnd(m_S_fwd,sigma_S);
      int_sig_spl_fwd=normrnd(m_I_fwd,sigma_I_fwd);
      tot_int_sig_spl_fwd=10*log10(sum(10.^(int_sig_spl_fwd/10)));
      SIR_spl_fwd_2B(i)=des_sig_spl_fwd-tot_int_sig_spl_fwd;
      des_sig_spl_rev=normrnd(m_S_rev,sigma_S);
      int_sig_spl_rev=normrnd(m_I_rev,sigma_I_rev);
      tot_int_sig_spl_rev=10*log10(sum(10.^(int_sig_spl_rev/10)));
      SIR_spl_rev_2B(i)=des_sig_spl_rev-tot_int_sig_spl_rev;
   if SIR_spl_fwd_2B(i)<SIR_target
         Num_B_fwd=Num_B_fwd+1;
   end
   if SIR_spl_rev_2B(i)<SIR_target
         Num_B_rev=Num_B_rev+1; 
   end
  end 
  P_fwd_average_outage(SIR_target+1)=P_fwd_outage/num_snapshots;
  P_rev_average_outage(SIR_target+1)=P_rev_outage/num_snapshots;
  P_fwd_outage_A(SIR_target+1)= Num_A_fwd/num_snapshots;
  P_rev_outage_A(SIR_target+1)= Num_A_rev/num_snapshots;
  P_fwd_outage_B(SIR_target+1)= Num_B_fwd/num_snapshots;
  P_rev_outage_B(SIR_target+1)= Num_B_rev/num_snapshots;
end
n=SIR_target_lower:SIR_target_upper;
subplot(2,1,1)
plot(n,P_fwd_average_outage*100,'or-',n,P_fwd_outage_A*100,'vb-',n,P_fwd_outage_B*100,'*k-');
subplot(2,1,2)
plot(n,P_rev_average_outage*100,'or-',n,P_rev_outage_A*100,'vb-',n,P_rev_outage_B*100,'*k-');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -