46 lines
945 B
Matlab
46 lines
945 B
Matlab
function ds = read_syncdata(DATASET_DIR)
|
|
% settings
|
|
%DATASET_DIR = 'test_20221';
|
|
TS_FILE = 'ts';
|
|
SAMPLE_FILE_PREFIX = 'ch_';
|
|
FILE_EXT = 'dat';
|
|
CHANNELS = 2;
|
|
|
|
% computed values
|
|
FN_TS = strcat(DATASET_DIR, '/', TS_FILE, '.', FILE_EXT);
|
|
|
|
for ch=0:1:(CHANNELS-1)
|
|
FN_SAMPLE{ch+1} = strcat(DATASET_DIR, '/', SAMPLE_FILE_PREFIX, num2str(ch), '.', FILE_EXT);
|
|
end
|
|
|
|
|
|
% load timestamps
|
|
f = fopen(FN_TS ,'r');
|
|
ts = fread(f,[2,Inf],'uint32');
|
|
fclose(f);
|
|
|
|
% take first element as t0
|
|
%ts(1,:) = ts(1,:) - 1636036145;
|
|
|
|
% create fractional timestamp
|
|
ts = ts(1,:) + ts(2,:) / 1E+09;
|
|
|
|
% get sample count
|
|
sample_cnt = length(ts);
|
|
|
|
% load samples
|
|
s = zeros(CHANNELS, sample_cnt);
|
|
for ch=1:CHANNELS
|
|
f = fopen(FN_SAMPLE{ch},'r');
|
|
d = fread(f, [1,Inf],'int16');
|
|
s(ch,:) = d;
|
|
fclose(f);
|
|
end
|
|
|
|
%figure(1)
|
|
%plot(ts(1,1:100), s(1,1:100), 'x')
|
|
%xlim([ts(1) ts(100)])
|
|
%hold on
|
|
|
|
ds = [ts' s'];
|
|
end |