【E-DEEC】基于matlab增强的分布式能源有效集群(E-DEEC)【含Matlab源码 1566期】
        【摘要】 
                    
                        
                    
                    一、获取代码方式 
获取代码方式1: 完整代码已上传我的资源:【E-DEEC】基于matlab增强的分布式能源有效集群(E-DEEC)【含Matlab源码 1566期】 
获取代码方式2: 通过订阅紫极神...
    
    
    
    一、获取代码方式
获取代码方式1:
 完整代码已上传我的资源:【E-DEEC】基于matlab增强的分布式能源有效集群(E-DEEC)【含Matlab源码 1566期】
获取代码方式2:
 通过订阅紫极神光博客付费专栏,凭支付凭证,私信博主,可获得此代码。
备注:
 订阅紫极神光博客付费专栏,可免费获得1份代码(有效期为订阅日起,三天内有效);
二、部分源代码
clear all
xm=100;
ym=100;
sink.x=0.5*xm;  %location of sink on x-axis
sink.y=0.5*ym;  %location of sink on y-axis
n=100  %nodes+
P=0.1;  %probability of cluster heads
Eo=0.5;%initial energy
%
Echeck=Eo;
%
ETX=50*0.000000001;  %tx energy
ERX=50*0.000000001;  %rx energy
Efs=10*0.000000000001;  %free space loss
Emp=0.0013*0.000000000001;   %multipath loss
%Data Aggregation Energy
EDA=5*0.000000001;  %compression energy
a=1.5;   %fraction of energy enhancment of advance nodes
rmax=5000  %maximum number of rounds
do=sqrt(Efs/Emp);  %distance do is measured
Et=0;  %variable just use below
m=0.5;
mo=0.4;
b=3;
normal=n*(1-m);
advance=n*m*(1-mo);
monaysuper=n*m*mo;
for i=1:1:monaysuper
S(i).xd=rand(1,1)*xm;  %generates a random no. use to randomly distibutes nodes on x axis
XR(i)=S(i).xd;
S(i).yd=rand(1,1)*ym;  %generates a random no. use to randomly distibutes nodes on y axis
YR(i)=S(i).yd;
S(i).G=0; %node is elegible to become cluster head
%talhar=rand*a
S(i).E=Eo*(1+b);
%S(i).A=talhar;
E(i)= S(i).E;
%     if (E(i)>Echeck)
%         m1=m1+1;
%     end
Et=Et+E(i);  %estimating total energy of the network
%initially there are no cluster heads only nodes
S(i).type='N';
end
talha1=monaysuper+advance;
for i=monaysuper:1:talha1
S(i).xd=rand(1,1)*xm;  %generates a random no. use to randomly distibutes nodes on x axis
XR(i)=S(i).xd;
S(i).yd=rand(1,1)*ym;  %generates a random no. use to randomly distibutes nodes on y axis
YR(i)=S(i).yd;
S(i).G=0; %node is elegible to become cluster head
%talhar=rand*a
S(i).E=Eo*(1+a);
%S(i).A=talhar;
E(i)= S(i).E;
%     if (E(i)>Echeck)
%         m1=m1+1;
%     end
Et=Et+E(i);  %estimating total energy of the network
%initially there are no cluster heads only nodes
S(i).type='N';
end
for i=talha1:1:n
S(i).xd=rand(1,1)*xm;  %generates a random no. use to randomly distibutes nodes on x axis
XR(i)=S(i).xd;
S(i).yd=rand(1,1)*ym;  %generates a random no. use to randomly distibutes nodes on y axis
YR(i)=S(i).yd;
S(i).G=0; %node is elegible to become cluster head
%talhar=rand*a
S(i).E=Eo;
%S(i).A=talhar;
E(i)= S(i).E;
%     if (E(i)>Echeck)
%         m1=m1+1;
%     end
Et=Et+E(i);  %estimating total energy of the network
%initially there are no cluster heads only nodes
S(i).type='N';
end
d1=0.765*xm/2;  %distance between cluster head and base station
K=sqrt(0.5*n*do/pi)*xm/d1^2; %optimal no. of cluster heads
d2=xm/sqrt(2*pi*K);  %distance between cluster members and cluster head
Er=4000*(2*n*ETX+n*EDA+K*Emp*d1^4+n*Efs*d2^2);  %energy desipated in a round
S(n+1).xd=sink.x; %sink is a n+1 node, x-axis postion of a node
S(n+1).yd=sink.y; %sink is a n+1 node, y-axis postion of a node
countCHs=0;  %variable, counts the cluster head
cluster=1;  %cluster is initialized as 1
flag_first_dead=0; %flag tells the first node dead
flag_teenth_dead=0;  %flag tells the 10th node dead
flag_all_dead=0;  %flag tells all nodes dead
dead=0;  %dead nodes count initialized to 0
first_dead=0;
teenth_dead=0;
all_dead=0;
allive=n;
%counter for bit transmitted to Bases Station and to Cluster Heads
packets_TO_BS=0;
packets_TO_CH=0;
for r=0:1:rmax
r
if(mod(r, round(1/P) )==0)
for i=1:1:n
S(i).G=0;
S(i).cl=0;
end
end
Ea=Et*(1-r/rmax)/n;
dead=0;
for i=1:1:n
if (S(i).E<=0)
dead=dead+1;
if (dead==1)
if(flag_first_dead==0)
first_dead=r;
flag_first_dead=1;
end
end
if(dead==0.1*n)
if(flag_teenth_dead==0)
teenth_dead=r;
flag_teenth_dead=1;
end
end
if(dead==n)
if(flag_all_dead==0)
all_dead=r;
flag_all_dead=1;
end
end
end
if S(i).E>0
S(i).type='N';
end
end
  
 - 1
 - 2
 - 3
 - 4
 - 5
 - 6
 - 7
 - 8
 - 9
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 - 41
 - 42
 - 43
 - 44
 - 45
 - 46
 - 47
 - 48
 - 49
 - 50
 - 51
 - 52
 - 53
 - 54
 - 55
 - 56
 - 57
 - 58
 - 59
 - 60
 - 61
 - 62
 - 63
 - 64
 - 65
 - 66
 - 67
 - 68
 - 69
 - 70
 - 71
 - 72
 - 73
 - 74
 - 75
 - 76
 - 77
 - 78
 - 79
 - 80
 - 81
 - 82
 - 83
 - 84
 - 85
 - 86
 - 87
 - 88
 - 89
 - 90
 - 91
 - 92
 - 93
 - 94
 - 95
 - 96
 - 97
 - 98
 - 99
 - 100
 - 101
 - 102
 - 103
 - 104
 - 105
 - 106
 - 107
 - 108
 - 109
 - 110
 - 111
 - 112
 - 113
 - 114
 - 115
 - 116
 - 117
 - 118
 - 119
 - 120
 - 121
 - 122
 - 123
 - 124
 - 125
 - 126
 - 127
 - 128
 - 129
 - 130
 - 131
 - 132
 - 133
 - 134
 - 135
 - 136
 - 137
 - 138
 - 139
 - 140
 - 141
 - 142
 
三、运行结果

四、matlab版本及参考文献
1 matlab版本
 2014a
2 参考文献
 [1] 沈再阳.精通MATLAB信号处理[M].清华大学出版社,2015.
 [2]高宝建,彭进业,王琳,潘建寿.信号与系统——使用MATLAB分析与实现[M].清华大学出版社,2020.
 [3]王文光,魏少明,任欣.信号处理与系统分析的MATLAB实现[M].电子工业出版社,2018.
文章来源: qq912100926.blog.csdn.net,作者:海神之光,版权归原作者所有,如需转载,请联系作者。
原文链接:qq912100926.blog.csdn.net/article/details/121777972
        【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
            cloudbbs@huaweicloud.com
        
        
        
        
        
        
        - 点赞
 - 收藏
 - 关注作者
 
            
           
评论(0)