www.gusucode.com > CDMA小区中断概率仿真源码程序 > CDMA小区中断概率仿真源码程序/源程序/c17_cellularsetup.m
clc; clear; close all; r_cell = 1000; % 小区半径 n_co_ch_users = 6; % 同频小区的数量 P_BS = 0; % 基站发射功率 P_MS = 0; % 移动台发射功率 corr_fwd = 0.0; % 前向链路相关系数 corr_rev = 0.0; % 后向链路相关系数 K = 1; % 常数 in_beam = 0; % 扇区化天线在扇区内的增益 % % 每一个扇区的角度限制 % 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; % % 每一个扇区的中心 % phi_center = zeros(6,3); phi_center(:,1) = (pi/3)*[-3:2]'; phi_center([1:3],2) = (pi/3)*[-3 -1 1]'; % % 每一个扇区的波束宽度 % phi_BW = [1 2 6]*pi/3; % % 扇区数量 % num_sectors = [6 3 1]; % 初始参数输入 num = input('仿真取值次数 = '); cluster_size = input('簇大小 (3, 4 or 7) = '); n_path = input('路径损耗指数 = '); sigma1 = input('阴影标准差 (dB) = '); sigma2 = input('有用信号标准差(dB) = '); sec = input('每个小区的扇区数 (1=>60度, 2=>120度, 3=>360度)='); ftb = input('基站扇区化天线的正反向比 (dB) = '); out_beam = in_beam - ftb; % 同频小区位置 a=0; b=0; theta_N=[pi/6 0 pi/6 asin(1/(2*sqrt(7)))]; theta=pi/3*[0:5]'; aux_1=[1 0 2 3 0 0 4]; ind=aux_1(cluster_size); bs_position=[sqrt(3*cluster_size)*r_cell*cos(theta+theta_N(ind)) sqrt(3*cluster_size)*r_cell*sin(theta+theta_N(ind))]; for f=1:num % 计算同频移动台和所研究的移动台的位置 sector=unidrnd(num_sectors(sec)); des_user_beta=rand(1)*phi_BW(sec)+phi_center(sector,sec); des_user_r=sqrt(rand(1).*(r_cell^2)); co_ch_user_beta=rand(6,1)*phi_BW(sec)+phi_center(sector,sec); co_ch_user_r=sqrt(rand(6,1))*(r_cell); 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; % 计算前向链路有用信号和总信道干扰的均值和标准差 m_S_fwd=P_BS-10*K*n_path*log10(des_user_r); 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); 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 m_I_fwd=P_BS-10*K*n_path*log10(d_I_fwd)+gain_fwd.'; sigma_I_fwd=sigma1*ones(length(m_I_fwd),1); [m_I_total_fwd,sigma_I_total_fwd]=wilkinson(m_I_fwd,sigma_I_fwd,corr_fwd); % 计算反向链路有用信号和总信道干扰的均值和标准差 m_S_rev=P_MS-10*K*n_path*log10(des_user_r); 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); 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 m_I_rev=P_MS-10*K*n_path*log10(d_I_rev)+gain_rev.'; sigma_I_rev=sigma1*ones(length(m_I_rev),1); [m_I_total_rev,sigma_I_total_rev]=wilkinson(m_I_rev,sigma_I_rev,corr_rev); %计算SIR的均值和标准差 m_SIR_fwd=m_S_fwd-m_I_total_fwd; sigma2IR_fwd=sqrt(sigma2^2+sigma_I_total_fwd^2-2*corr_fwd*sigma2*sigma_I_total_fwd); m_SIR_rev=m_S_rev-m_I_total_rev; sigma2IR_rev=sqrt(sigma2^2+sigma_I_total_rev^2-2*corr_rev*sigma2*sigma_I_total_rev); a=a+m_SIR_fwd; b=b+sigma2IR_fwd; end % 计算中断概率 SIR0=(0:5:40)'; m_SIR_fwd=a/num; sigma2IR_fwd=b/num; h=1-qfunc((SIR0-m_SIR_fwd)/sigma2IR_fwd); plot(SIR0,h,'r-p') axis([0,40,0,1]) xlabel('阈值SIR0/dB') ylabel('中断概率/%') grid on