forked from yueyuzhao/gyrophone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmerge_sensor_data.m
More file actions
28 lines (23 loc) · 869 Bytes
/
merge_sensor_data.m
File metadata and controls
28 lines (23 loc) · 869 Bytes
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 [merged_timestamps, merged_samples, merged_fs] = ...
merge_sensor_data(timestamps, samples, offsets, fs)
num_devices = length(samples);
shift = max(offsets) - offsets;
% trim recordings according to offsets
% figure; hold all;
for i = 1:num_devices
if ~isempty(timestamps)
trimmed_timestamps{i} = timestamps{i}(shift(i)+1:end);
end
trimmed_samples{i} = samples{i}(shift(i)+1:end);
% plot(trimmed_samples{i});
end
% title('Trimmed signals');
if ~isempty(timestamps)
merged_timestamps = interleave_vectors(trimmed_timestamps);
else
merged_timestamps = [];
end
merged_samples = interleave_vectors(trimmed_samples);
merged_fs = fs * num_devices;
% [~, gyro_merged] = interpolate_samples(merged_timestamps, gyro_merged);
end