SampleReceiver/MATLAB/read_syncdata.m
Wiesner András 22233ce62d - earlier capabilities are accessible from Python
- MultiStreamReceiver and SampleWriter cleaned
- AcquisitionFormat introduced
- Logger created
- MultiStreamProcessor idea introduced, MultiStreamToFile introduced
- MATLAB scripts have been modified to load new capture folder structure
- began implementing MultiStreamOscilloscope
2022-05-05 00:11:48 +02:00

50 lines
1.0 KiB
Matlab

function ds = read_syncdata(data_files)
% settings
%DATASET_DIR = 'test_20221';
TS_FILE_EXT = 'ts';
%SAMPLE_FILE_PREFIX = 'ch_';
SAMPLE_FILE_EXT = 'dat';
%CHANNELS = 2;
%for ch=0:1:(CHANNELS-1)
% FN_SAMPLE{ch+1} = strcat(data_files, '/', SAMPLE_FILE_PREFIX, num2str(ch), '.', SAMPLE_FILE_EXT);
%end
[files_n,~] = size(data_files);
s = [];
ts = [];
for i=1:files_n
data_file = data_files(i,:);
% load timestamps
FN_TS = strcat(data_file, '.', TS_FILE_EXT);
f = fopen(FN_TS ,'r');
d = fread(f,[2,Inf],'uint32');
fclose(f);
% create fractional timestamp
d = d(1,:) + d(2,:) / 1E+09;
ts = [ts; d];
% get sample count
%sample_cnt = length(ts);
% load samples
FN_SAMPLE = strcat(data_file, '.', SAMPLE_FILE_EXT);
f = fopen(FN_SAMPLE,'r');
d = fread(f, [1,Inf],'int16');
s = [s; 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