39 lines
754 B
Matlab
39 lines
754 B
Matlab
% settings
|
|
DATASET_DIR = 'test';
|
|
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,:) - ts(1,1);
|
|
|
|
% 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
|
|
|
|
plot(ts(1,1:100), s(1,1:100)) |