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

📄 is_connected_boolean.asv

📁 无线ADHOC网络中
💻 ASV
字号:
%**************************************************************************
%**  File name : is_connected_boolean.m
%**  Author  : Liufengwei (English name:andy)
%**  Creation date : 4,23,2007,Monday
%**  Modified date: 
%**  Parameter explanation : See the note in the program
%**************************************************************************
% ** Input: NodesXY--the coordinate of point in two dimensional--size:Nodenum*2
%                range--transmission range of every node
% ** output: y--if the network is connected,return1;else return 0
% ** Goal: simulate the formula in paper<On the minimum node degree and connectivity of a wireless multihop network>
% ** Explanation :  We calculate whether the network is connected if every
%       node has the same transmission range by flooding algorithm 
%** Program process: initialize simulation parameter, then 
%************************************************************************

function y = is_connected_boolean(NodesXY, range)  

%***********first initialize simulaiton parameters***************
Nodenum = length(NodesXY) ; % nodenum
cluster = zeros(1, Nodenum) ; % store the nodes belong to the cluster
temp_dis  = zeros(1, Nodenum);
Nodes_dis = zeros(1, (Nodenum-1)); % store the node distance

cluster_down = 1;
cluster_sum =1 ;  % the sum number of nodes in the cluster
index =1 ; % the node index in cluster 

for n =1 : Nodenum  
  
         temp_dis = sqrt(sum((NodesXY - ones(Nodenum, 1)*NodesXY(n,:))'.^2)) ;
         Nodes_dis = temp_dis(temp_dis>0) ; % Nodes_dis:1*((Nodenum-1))
         con_to_n = Nodes_dis(Nodes_dis<=range) ; % store the nodes connected to node n
         
         cluster_sum = cluster_down+sum(con_to_n);
end % for run=1 : run_times

simu_Pdmin = G_than_N0/run_times ; %calculate the prob of degree of every node greater than N0
% Pdmin_N=prod(G_than_N0);

%**********Calculate the analytical prob********************

A = square_edge^2 ; % the area of system plane
for i = 1: Len_N0
   j = 1;
   for radio = Radio_down: Radio_step: Radio_up
         for N=0 : N0(i)-1 
            ana_Pdmin(i,j)=((Nodenum/A)*pi*radio^2)^N/factorial(N)+ana_Pdmin(i,j);
         end
            ana_Pdmin(i,j)=(1-ana_Pdmin(i,j)*exp(-(Nodenum/A)*pi*radio^2))^Nodenum;
         j = j+1;
   end
end
%*******************draw figure************************

figure(1)
plot(Radio,simu_Pdmin(1,:),'ro-',Radio,ana_Pdmin(1,:),'k-',Radio,simu_Pdmin(2,:),'r*-',Radio,ana_Pdmin(2,:),'k--',Radio,simu_Pdmin(3,:),'rsquare-',Radio,ana_Pdmin(3,:),'k-.');
grid on;
legend('\it simP(d_min>=1)','\ita analytical P(d_min>=1)','\it simP(d_min>=2)','\ita analytical P(d_min>=2)','\it simP(d_min>=3)','\ita analytical P(d_min>=3)'); 
hold on
axis([Radio_down Radio_up 0 1])
xlabel('range(in m)','color','b')
ylabel('prob for d_min','color','b')
title(' P(dmin>=N0 with Euclidian distance metric)')

toc

⌨️ 快捷键说明

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