电子产业一站式赋能平台

PCB联盟网

搜索
查看: 1000|回复: 5
收起左侧

求指导,蜂窝无线通信系统仿真

[复制链接]

568

主题

922

帖子

4783

积分

四级会员

Rank: 4

积分
4783
发表于 2023-5-11 21:36:43 | 显示全部楼层 |阅读模式
仿真不出来,出现错误
仿真取值次数 = 2簇大小 (3, 4 or 7) = 4路径损耗指数 = 4阴影标准差 (dB) = 8有用信号标准差(dB) = 8每个小区的扇区数 (1=>60度, 2=>120度, 3=>360度)=2基站扇区化天线的正反向比 (dB) = 30??? Error using ==> wilkinsonToo many input arguments.
Error in ==> Untitled4 at 86[m_I_total_fwd,sigma_I_total_fwd]=wilkinson(m_I_fwd,sigma_I_fwd,corr_fwd);
回复

使用道具 举报

10

主题

905

帖子

812

积分

二级会员

Rank: 2

积分
812
发表于 2023-5-11 21:36:52 | 显示全部楼层
代码
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
回复 支持 反对

使用道具 举报

2

主题

849

帖子

648

积分

二级会员

Rank: 2

积分
648
发表于 2023-5-11 21:37:37 | 显示全部楼层
代码,上面太乱了
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
回复 支持 反对

使用道具 举报

0

主题

825

帖子

674

积分

二级会员

Rank: 2

积分
674
发表于 2023-5-11 21:37:55 | 显示全部楼层
想弱弱的问一句,仿真怎么得出那个图呢?
回复 支持 反对

使用道具 举报

591

主题

1774

帖子

5769

积分

四级会员

Rank: 4

积分
5769
发表于 2023-5-11 21:38:03 | 显示全部楼层
你好,请问楼主做出来了吗?我也在做这个,求大神指导!
回复 支持 反对

使用道具 举报

2

主题

849

帖子

648

积分

二级会员

Rank: 2

积分
648
发表于 2023-5-11 21:38:19 | 显示全部楼层
求大神指导
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


联系客服 关注微信 下载APP 返回顶部 返回列表