clc;
clear;
close all;
warning off;
addpath(genpath(pwd));
rng('default')
global fc_LTE ...%LTE频率
fc_Wimax1 ...%Wimax1频率
fc_Wimax2 ...%Wimax2频率
LTE_BS_coordinate ...%LTE基站坐标
Wimax1_BS_coordinate ...%Wimax基站坐标
Wimax2_BS_coordinate ...%Wimax基站坐标
large_scale_time_interval...
large_scale_LTE ...
large_scale_wimax ...
large_scale_time_start ...
large_scale_time_end ...
N
service_type=0; %the subscriber type of service
%0 refers to real time service,on the
% contrary,1 refers to nonreal-time service
large_scale_time_interval=100;
N=10;
large_scale_time_start=0;
large_scale_time_end=large_scale_time_interval;
large_scale_LTE=ShadowGenerate(3,0.5,N);
large_scale_wimax=ShadowGenerate(3,0.5,N);
MS_coordinate=[0,0];
LTE_BS_coordinate=[0,0]; %the coordinate of LTE BS
Wimax1_BS_coordinate=[400,0]; %the coordinate of wimax1 BS
Wimax2_BS_coordinate=[550,0]; %the coordinate of wimax2 BS
MS_speed=5; %the speed of mobile station
Net_state=0; %0 refers to LTE;1 refers to Wimax1;2 refers to Wimax2
handoff_drop=1;
handoff_clock=0;
count_handoff_number=0;
Tc=0.2; %time of measure interval
record_time=0; %record the number of interval time of system
wb=0.5;
wSNR=0.5;
% Ba=1;%网络的可利用带宽
% Bt=5;%网络的总带宽
Pth=-80;%接收功率门限
% Pmax=40;%最大发射功率
Gr=1;%接收天线增益
Gt=1;%发射天线增益
L=1;%综合损耗
ds=[0 400 550];
fc_LTE=2300*10^6;
fc_Wimax1=2500*10^6;
fc_Wimax2=2600*10^6;
Pmax_LTE=40;
Pmax_Wimax=23;
% d=zeros(1,3);
dm=[1000 300 300];
Bt=[5 16.5 16.5];
% ci=['.b' '.r' '.p'];
ui1=zeros(1000);
ui2=zeros(1000);
ui3=zeros(1000);
countinue_run=true;
while countinue_run
%################# measure the receieved signal strength ############
%if the mobile station is in the LTE network
if is_in_LTE_coverage(MS_coordinate)
RSS_LTE=calculate_RSS(MS_coordinate,MS_speed,'LTE',record_time*Tc,Tc);
% x=wgn(1,1,0,'dBw');
% RSS_LTE=RSS_LTE-x;
Ba_LTE=Bt(1)-(0.384+1+2);
Bi_LTE=Ba_LTE/Bt(1);
%计算效用函数
d=norm(MS_coordinate-LTE_BS_coordinate);
% x=wgn(1,1,0);
% RSS_LTE=Pmax_LTE-L-10*(2+1)*log10(d)-x;%网络的当前信号强度*rand()
x=0;%wgn(1,1,0);
RSS_LTE=RSS_LTE-L-10*(2+1)*log10(d)-x;%网络的当前信号强度*rand()
%COST_LTE=wrss*log(1/RSS_LTE)+wd*log(d1)+wb*log(1/vb)+wc*log(vc)+wl*log(1/vlive);
S_LTE=(RSS_LTE-Pth)/(Pmax_LTE-Pth);
% S_LTE=(RSS_LTE)/(Pmax_LTE);
U_LTE=wSNR*log(S_LTE)+wb*log(Bi_LTE);
else
RSS_LTE=-inf;
% COST_LTE=-inf;20*
U_LTE=-inf;
end
%if the mobile station is in the Wimax1 network
if is_in_Wimax1_coverage(MS_coordinate)
RSS_Wimax1=calculate_RSS(MS_coordinate,MS_speed,'Wimax1',...
record_time*Tc,Tc);
% x=wgn(1,1,0,'dBw');
% RSS_Wimax1=RSS_Wimax1-x;
Ba_Wimax1=Bt(2)-(0.384+1+2);
Bi_Wimax1=Ba_Wimax1/Bt(2);
%计算cost
d=norm(MS_coordinate-Wimax1_BS_coordinate);
% x=wgn(1,1,0);
% RSS_Wimax1=Pmax_Wimax-L-10*(2+1)*log10(d)-x;%网络的当前信号强度*rand()
x=0;%wgn(1,1,0);
RSS_Wimax1=RSS_Wimax1-L-10*(2+1)*log10(d)-x;%网络的当前信号强度*rand()
%COST_Wimax=wrss*log(1/RSS_Wimax)+wd*log(d1m)+wb*log(1/vbm)+wc*log(vcm)+wl*log(1/vlivem);
S_Wimax1=(RSS_Wimax1-Pth)/(Pmax_Wimax-Pth);
% S_Wimax1=(RSS_Wimax1)/(Pmax_Wimax);
U_Wimax1=wSNR*log(S_Wimax1)+wb*log(Bi_Wimax1);
else
RSS_Wimax1=-inf;
% COST_Wimax=-inf;20*
U_Wimax1=-inf;
end
%if the mobile station is in the Wimax2 network
if is_in_Wimax2_coverage(MS_coordinate)
RSS_Wimax2=calculate_RSS(MS_coordinate,MS_speed,'Wimax2',...
record_time*Tc,Tc);
% x=wgn(1,1,0,'dBw');
% RSS_Wimax2=RSS_Wimax2-x;
Ba_Wimax2=Bt(2)-(0.384+1+2);
Bi_Wimax2=Ba_Wimax2/Bt(2);
%计算cost
d=norm(MS_coordinate-Wimax2_BS_coordinate);
% x=wgn(1,1,0);
% RSS_Wimax2=Pmax_Wimax-L-10*(2+1)*log10(d)-x;%网络的当前信号强度*rand()
x=0;%wgn(1,1,0);
RSS_Wimax2=RSS_Wimax2-L-10*(2+1)*log10(d)-x;%网络的当前信号强度*rand()
%COST_Wimax=wrss*log(1/RSS_Wimax)+wd*log(d1m)+wb*log(1/vbm)+wc*log(vcm)+wl*log(1/vlivem);
S_Wimax2=(RSS_Wimax2-Pth)/(Pmax_Wimax-Pth);
% S_Wimax2=(RSS_Wimax2)/(Pmax_Wimax);
U_Wimax2=wSNR*log(S_Wimax2)+wb*log(Bi_Wimax2);
else
RSS_Wimax2=-inf;
% COST_Wimax=-inf;20*
U_Wimax2=-inf;
end
%############### decide whether to handoff according to RSS #########
% if Net_state~=0&&RSS_LTE>RSS_Wimax1&&RSS_LTE>RSS_Wimax2
if Net_state~=0&&U_LTE>U_Wimax1&&U_LTE>U_Wimax2
if handoff_clock>handoff_drop
count_handoff_number=count_handoff_number+1;
Net_state=0;
handoff_clock=0; %reset the counter
else
handoff_clock=handoff_clock+Tc;
end
% elseif Net_state~=1&&RSS_Wimax1>RSS_LTE&&RSS_Wimax1>RSS_Wimax2
elseif Net_state~=1&&U_Wimax1>U_LTE&&U_Wimax1>U_Wimax2
if handoff_clock>handoff_drop
count_handoff_number=count_handoff_number+1;
Net_state=1;
handoff_clock=0; %reset the counter
else
handoff_clock=handoff_clock+Tc;
end
% elseif Net_state~=2&&RSS_Wimax2>RSS_LTE&&RSS_Wimax2>RSS_Wimax1
elseif Net_state~=2&&U_Wimax2>U_LTE&&U_Wimax2>U_Wimax1
if handoff_clock>handoff_drop
count_handoff_number=count_handoff_number+1;
Net_state=2;
handoff_clock=0; %reset the counter
else
handoff_clock=handoff_clock+Tc;
end
else
handoff_clock=0;
end
%##################### decide whether to continue run ################
if is_in_LTE_coverage(MS_coordinate)||...
is_in_Wimax1_coverage(MS_coordinate)||...
is_in_Wimax2_coverage(MS_coordinate)
%######################## record the data ########################
record_time=record_time+1;
record_RSS_LTE(record_time)=RSS_LTE;
record_RSS_Wimax1(record_time)=RSS_Wimax1;
record_RSS_Wimax2(record_time)=RSS_Wimax2;
% record_COST_LTE(record_time)=COST_LTE;
% record_COST_Wimax(record_time)=COST_Wimax;
record_U_LTE(record_time)=U_LTE;
record_U_Wimax1(record_time)=U_Wimax1;
record_U_Wimax2(record_time)=U_Wimax2;
record_Net_state(record_time)=Net_state;
MS_coordinate(1)=MS_coordinate(1)+MS_speed*Tc;
else
countinue_run=false;
end
end
%######################## plot the simulation results ####################
t=[1:record_time];
plot(t,record_U_LTE,'-bo','MarkerEdgeColor','b','MarkerFaceColor','y',...
'MarkerSize',2);
hold on
plot(t,record_U_Wimax1,'-ms','MarkerEdgeColor','m',...
'MarkerFaceColor','c','MarkerSize',2);
plot(t,record_U_Wimax2,'-rs','MarkerEdgeColor','r',...
'MarkerFaceColor','c','MarkerSize',2);
hold off
grid on
axis([0 1000 -1.6 0]);
xlabel('行程(m)');
ylabel('效用函数值');
% legend('TD-SCDMA','Wimax1','Wimax2');
legend('UMTS','WLAN1','WLAN2');
% title('the received signal strength about two networks');
title('网络效用函数值');
figure
plot(t,record_Net_state,'--ro','MarkerEdgeColor','g','MarkerFaceColor','y',...
'MarkerSize',2)
grid on
xlabel('距离(m)');
ylabel('网络');
text(0,0,'\leftarrow TD-SCDMA','FontSize',9)
text(0,1,'\leftarrow Wimax1','FontSize',9)
text(0,2,'\leftarrow Wimax2','FontSize',9)
title(
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
1.版本:matlab2022A,包含仿真操作录像,操作录像使用windows media player播放。 2.领域:垂直切换 3.仿真效果:仿真效果可以参考博客同名文章《基于TD-SCDMA与WiMax异构网络的垂直切换算法matlab仿真》 4.内容:基于TD-SCDMA与WiMax异构网络的垂直切换算法matlab仿真。基于TD-SCDMA与WiMax异构网络的垂直切换是一种关键技术,它允许用户在不同类型的无线网络之间无缝切换,以提供更好的用户体验和网络效率。TD-SCDMA(时分同步码分多址)和WiMax(全球微波互联接入)是两种不同的无线通信标准,它们具有不同的物理层特性和网络配置。 5.注意事项:注意MATLAB左侧当前文件夹路径,必须是程序所在文件夹位置,具体可以参考视频录。
资源推荐
资源详情
资源评论
收起资源包目录
基于TD-SCDMA与WiMax异构网络的垂直切换算法matlab仿真.rar (11个子文件)
20240119_161022.mp4 4.89MB
code
Runme.m 8KB
func
calculate_fast_fading.m 885B
is_in_Wimax2_coverage.m 261B
calculate_slow_fading.m 698B
is_in_Wimax1_coverage.m 261B
is_in_LTE_coverage.m 245B
ShadowGenerate.m 263B
calculate_shadow_fading.m 883B
jakes.m 620B
calculate_RSS.m 924B
共 11 条
- 1
资源评论
fpga和matlab
- 粉丝: 15w+
- 资源: 2548
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功