-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathclear_decoded_data.m
29 lines (25 loc) · 1.14 KB
/
clear_decoded_data.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
function decodedDataCell = clear_decoded_data(decodedDataCell)
% calculate speed based on position/time
count = 1;
index_to_remove = [];
for i = 1:size(decodedDataCell, 1)-1
if (decodedDataCell{i,1}.plane == decodedDataCell{i+1,1}.plane)
airplane_loc1 = lla2ecef([decodedDataCell{i,1}.lat, ...
decodedDataCell{i,1}.lon, decodedDataCell{i,1}.alt]);
airplane_loc2 = lla2ecef([decodedDataCell{i+1,1}.lat, ...
decodedDataCell{i+1,1}.lon, decodedDataCell{i+1,1}.alt]);
distance = sqrt(sum((airplane_loc2-airplane_loc1).^2));
start_time = max(decodedDataCell{i,1}.even_cprtime, decodedDataCell{i,1}.odd_cprtime);
end_time = max(decodedDataCell{i+1,1}.even_cprtime, decodedDataCell{i+1,1}.odd_cprtime);
speed = distance/(end_time-start_time)*1e7;
if (speed > 250)
index_to_remove(count) = i+1;
count = count+1;
end
end
end
% remove data that gives wrong speed
if (~isempty(index_to_remove))
decodedDataCell([index_to_remove], :) = [];
end
end