-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_free_falls.m
35 lines (35 loc) · 1.02 KB
/
find_free_falls.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
function edges = find_free_falls(time, values, threshold)
count = 0;
tolerance = 0.1;
edges = [];
begin = 0;
for i=2:length(values)
count_inc = (time(i) - time(i-1))/10;
if(count < threshold)
if values(i) <= (values(i-1)) && values(i) < 12
if count == 0
begin = time(i-1);
min_value = values(i);
end
count = count+count_inc;
elseif values(i) <= values(i-1)
count = count - 2*count_inc;
if count < 0
count = 0;
end
else
count = 0;
end
else
if values(i) < min_value
count = count + count_inc;
min_value = values(i);
elseif values(i) < min_value + tolerance*2
count = count + count_inc;
else
edges = [edges; [begin, time(i-1)], values(i-1)];
count = 0;
end
end
end
end