-
大小: 4KB文件类型: .rar金币: 1下载: 0 次发布日期: 2021-04-18
- 语言: Matlab
- 标签: Spin-MATLAB sensor network matlab-spin routing wireless
资源简介
Matlab code of SPIN Routing Protocol in Wireless Sensor Network
代码片段和文件信息
function [bal_energybal_energy_recnodes_inrangeqrequestersrand_valdS]=adv(advertiserSn)
bal_energy_receiver=0;
disp(‘********************************************************‘);
if(S(advertiser).E>0)
disp(‘in function adv & display advertiser‘);
disp(advertiser);
d1=0;
radius=20;
q=0;
for j=1:1:n
distance=sqrt( (S(advertiser).xd-(S(j).xd) )^2 + (S(advertiser).yd-(S(j).yd) )^2 ); %Finding nodes in advertiser‘s range
if(j~=advertiser)
if (distance<=radius)
q=q+1;
S(advertiser).in_range(q)=j; %Storing in range nodes in array in_range()
S(advertiser).dist(q)=distance; %Storing distances of in range nodes in array dist()
end
end
end
nodes_inrange= S(advertiser).in_range();
disp(‘Total number of nodes in range‘);
disp(q);
disp(‘in function adv & display in range‘);
for t=1:1:q
disp(S(advertiser).in_range(t));
end
% Average Distance of advertised nodes
disp(‘average distance‘);
for i=1:1:q
d1=d1+S(advertiser).dist(i);
end
d=d1/q;
disp(d);
% Finding request nodes
rand_val=round(rand(11)*10);
disp(‘rand_val‘);
disp(rand_val);
if(rand_val>q)
rand_val=q;
end;
for i=1:1:rand_val
S(advertiser).request(i)=S(advertiser).in_range(i);
end
disp(‘request nodes‘);
for i=1:1:rand_val
disp(S(advertiser).request(i));
end
requesters=S(advertiser).request();
%req=S(advertiser).request();
%Eelec=Etx=Erx
ETX=50*0.000001;
%ETX=50*0.000000001;
ERX=50*0.0000000001;
%Transmit Amplifier types
Efs=0.015*0.00000000001;
Emp=0.0013*0.000000000001;
%Data Aggregation Energy
EDA=5*0.000000001;
energy_loss =( (ETX)*(4000) + Emp*4000*( d*d*d*d ));
disp(‘energy_loss of advertiser node is‘);
disp(energy_loss);
bal_energy = S(advertiser).E-energy_loss;
disp(‘balance energy of adv node is‘);
disp(bal_energy);
disp(‘energy loss of recievers in receiving the adv packet‘);
energy_loss_rec=( (ERX)*(4000) + Efs*4000*(d*d*d*d));
disp(energy_loss_rec);
for i=1:1:q
bal_energy_receiver(i)=S(S(advertiser).in_range(i)).E;
end
for i=1:1:q
bal_energy_receiver(i)=bal_energy_receiver(i)-energy_loss_rec;
end
bal_energy_rec=bal_energy_receiver();
end
if(S(advertiser).E<=0)
disp(‘advertiser has no energy‘);
bal_energy=0;
bal_energy_rec=0;
nodes_inrange=0;
q=0;requesters=0;rand_val=0;d=0;
end
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2712 2013-04-10 15:12 SPIN_BASIC\adv.m
文件 1503 2013-04-10 15:12 SPIN_BASIC\data_send.m
文件 1380 2013-04-10 15:12 SPIN_BASIC\request.m
文件 5116 2013-04-10 15:11 SPIN_BASIC\spin.m
目录 0 2013-06-07 13:41 SPIN_BASIC
----------- --------- ---------- ----- ----
10711 5
- 上一篇:多智能体系统一致性程序
- 下一篇:SAMP 稀疏度自适应匹配追踪算法
相关资源
- Fuzzy Neural Network by matlab 四个不同的
- matlab神经网络43个案例分析的代码及数
- 30 Bus Network2 Kabiri
- distribution-network-reconfiguration 电力系统
- 移动ad hoc网络路由协议仿真 (ad-hoc
- PMSM_sensorless 永磁同步电机无速度传感
- Cellular-Neural-Network 细胞神经网络(C
- Code2817164
- MANET
- LPR-neural-network 我自己做的一个基于神
- neural-network-of-multi-sensor 基于模糊神经
- MATLAB-Neural-network-cases 共有30个MATLAB神
- Matlab-co-interference 蜂窝小区同频干扰的
- Wavelet-network-timeseries 使用小波神经网
- BP-Load-forecasting 基于BP神经网络的短期
- DGnetwork1
- MATLAB-Identification-number 基于matlab 写的
- artificial-neural-network-method 基于人工神
- complex_network 用matlab所写的复杂网络所
- DGnetwork 微电源并网
- project
- DeepNeuralNetwork 深度学习DBN神经网络工
- fuzzy-network 模糊神经网络的资料和代码
- complex-network 复杂网络工具箱
- BP-neural-network-predict-- 利用MATLAB的自带
-
Physical-la
yer-Network 物理层的网络编码 - recurrent_network 用matlab编写的动态递归
- fuzzy-neural-network 模糊神经网络
- Neural-network-intelligent-control 机器人手臂
- Robot-fuzzy-neural-network2 机器人模糊神经
评论
共有 条评论