-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitorCel_F.m
39 lines (37 loc) · 1.15 KB
/
monitorCel_F.m
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
%[T F] = monitorCel(C_obj,S_network,STS_obj,index): is a function that takes a clock
%object, a swarm's network, a steretaxic space object, and an index, and
%returns the average magnetic field intensisty of the indexed cell measured
%for all time.
function [T, F] = monitorCel_F(C_obj,S_network,STS_obj,index)
%generate a storage matrix with the dimensions of time and number of drones
T = C_obj.timeline(:,2);
M = ones(length(T),length(S_network));
M = -M;
%Fill out storage matrix only when measurements are taken in the indexed
%cell
for i = 1:length(S_network)
for j = 1:length(T)
bool = checkR(S_network{i}.r(:,j),index,STS_obj);
if bool == 1
M(j,i) = S_network{i}.D_m(j,7);
end
end
end
%disp(M(1:10,:))
%Get cell average for each time step
F = zeros(height(M),1);
for i = 1:height(M)
x = 0;
for j = 1:width(M)
if M(i,j)>0
F(i) = F(i)+M(i,j);
%disp(M(i,j))
x = x+1;
end
if x > 0
F(i) = F(i)/x;
else
fprintf("no measurements for this cell at %d \n",T(i))
end
end
end