资源简介
基于Matlab,对Heed的分簇给出仿真代码,实现无线传感网的能量控制
代码片段和文件信息
% Heed分簇算法仿真(基于matlab)2007-12-16 13:38程序本身还是有问题的,但也贴出来了,网上公开的资料实在太少。
NodeNums = 1000; % the num of node
AreaR = 2000 ; % the area of simulate
NodeTranR=10; % the transit Radius
Elec=50 * 10^(-9); %
Eamp=100*10^(-12);
Bx=0; % The Postion of baseation
By=AreaR+400;
MaxInteral = 100; % the leach simulate time
Pch=0.05; % the desired percentage of cluster heads
InitEn=4; % the init energy of all node
MaxEn=InitEn;
Tr=100; % the time of round
Kbit=2000; % the bits of a node transmiting a packet every time
Gathingcoefficient=0.8;
BandWitch = 1*10.^(6); % Channel Bandwitch
Threshold=0; % the threshold of node becoming a cluster-head
TDMA=400;
Cprob=0.04;
NON_CH = 0;% // non cluster head
TENTATIVE_CH = 1; % // tentative cluster head
FINAL_CH = 2;% // final cluster head
sym ClusterHeadNum ;
ClusterHeadNum=0;
TOS_LOCAL_ADDRESS = -1; % TOS_LOCAL_ADDRESS must <=0
for i=1:(MaxInteral)
AliveNode(i)=NodeNums;
end
% Node.x=AreaR*rand(1NodeNums); % the position of node
% Node.y=AreaR*rand(1NodeNums);
sym buchang;
buchang = (AreaR/NodeNums);
% buchang=int(buchang);
Node.x=0:buchang:(buchang.*(NodeNums-1)); % the position of node
Node.y=0:buchang:(buchang.*(NodeNums-1));
Node.IsClusterHeads=linspace(00NodeNums); % NON_CHTENTATIVE_CHFINAL_CH
Node.IsCovered=linspace(00NodeNums); % Have Been Covered by a cluster head 1:yes 0:No
Node.c=linspace(00NodeNums); % the Cluster head of node
Node.chcost=linspace(00NodeNums); % the Cluster head of node
Node.d=linspace(00NodeNums); % the distance between cluster head and node
Node.l=zeros(1NodeNums)+Kbit; % the length of node i transmit packet
Node.EnNode=zeros(1NodeNums)+InitEn; % the init energy of all node
Node.StateNode=ones(1NodeNums); % the State of all node 1: alive 0:dead
Node.Listothernode=zeros(NodeNums); % if node is a cluster headListothernode save the id of node belong to this cluster
Node.csize=linspace(00NodeNums); % cluser size each cluster node num
Node.Nbr=zeros(NodeNums); % neighbor of node
Node.NumNbr=linspace(00NodeNums); % the neighbor‘s num of node
%Node.DistNbr=linspace(00NodeNums); % the neighbor‘s dist of node
Node.CHprob=zeros(1NodeNums)+Cprob;
Node.InitCHprob=zeros(1NodeNums);
Node.tent_CH=zeros(1NodeNums)+NON_CH;
Node.tent_CH_Cost=ones(1NodeNums)+9999;
Node.IsaddDummyRound=linspace(00NodeNums);
Node.n_finalCH=linspace(00NodeNums);
Node.ListfinalCH=zeros(NodeNums);
Node.ListfinalCH_Cost=zeros(NodeNums)+9999;
Node.n_tentCH=linspace(00NodeNums);
Node.ListtentCH=zeros(NodeNums);
Node.ListtentCH_Cost=zeros(NodeNums)+9999;
Node.my_fin
- 上一篇:无线传感网络的能量控制
- 下一篇:Contourlet工具箱
评论
共有 条评论