📄 measurement.asv
字号:
function [ distances count list] = measurement(sensors, leader, slot, detect_max, com_radius)
% Measure the distances
%
% INPUT
% sensors(:) : the location of the sensors
% leader : the leader at time t
% slot(:) : the loaction of an object at time t
% OUPUT
% distances() : an array of distance from an object to a sensor
% count : the count of sensors that can detect
% list() : the list of sensors
%
% Measure the distances from the neighbors of the leader
% that can detect to an object
distances = 0;
count = 0;
list = 0;
for num = 1:400
leader_sensor = (sensors(1,num)-sensors(1,leader))^2+(sensors(2,num)-sensors(2,leader))^2;
sensor_object = (sensors(1,num)-slot(1,1))^2 + (sensors(2,num)-slot(2,1))^2;
if leader_sensor <= com_radius^2 && sensor_object <=detect_max^2
if list == 0;
list = num;
distances = sqrt(sensor_object);
else
list = [list,num];
distances = [distances,sqrt(sensor_object)];
end
count = count + 1;
end
end
distances = distances*randint(1,10,[8000,12000])*0.0001
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -