function [neighbours , succ] = find_neighbours(forwarder,sink, accRange,...
numNodes,nodePositions)
k=0;
succ=0;
neighbours = [];
index = 1;
% copy x/y/z co-ordinates of forwarding node
fx=nodePositions(forwarder,1);
fy=nodePositions(forwarder,2);
fz=nodePositions(forwarder,3);
% Check whether sink is neighbour
sink_x = sink(1,1);
sink_y = sink(1,2);
sink_z = sink(1,3);
% find the distance between forwarder and sink
dst_sink = sqrt((fx- sink_x)^2 + (fy- sink_y)^2 + (fz- sink_z)^2);
% If sink is a neighbour, packets can send to sink Succesfuly
if( dst_sink <= accRange)
succ=1;
return;
end
for i=1: numNodes
if (forwarder == i)
continue;
end
% Copy x/y/z co-ordinates of neighbor
x=nodePositions(i,1);
y=nodePositions(i,2);
z= nodePositions(i,3);
distance = sqrt((fx-x)^2 + (fy-y)^2 + (fz-z)^2);
if ( distance <= accRange)
neighbours(index)=i;
index= index +1;
end
end
return
end
白话机器学习
- 粉丝: 1w+
- 资源: 7670
最新资源
- 现场评定检查表——建筑外墙、屋面保温和建筑外墙装饰.docx
- 现场评定检查表--气体灭火系统.docx
- 消防第三方技术服务模拟验收抽查记录表.doc
- 现场评定检查表——总平面布局.docx
- 消防验收过程服务--现场记录表.doc
- 消防第三方技术服务现场交底监督记录表.doc
- 向日葵被控端绿色精简运行版
- 学生心理档案表.docx
- 验收确认单表格.docx
- 阳宅净宅表文.docx
- 医疗废弃物建设项目环境风险简单分析表.docx
- 原材料检测报告.docx
- 造林补助实施方案小班一览表、造林补助(新增部分)分行政村(国有林场)任务落实情况表.xls
- 造林补助(新增部分)分行政村(国有林场)任务落实情况表.docx
- 肢体残疾标准.docx
- 职工工伤与职业病致残等级分级表十级.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈