22 lines
776 B
Matlab
22 lines
776 B
Matlab
function [data] = vector2timetable(data_path, varargin)
|
|
%VECTOR2TIMETABLE Load vector datalogger data and convert it to a timetable
|
|
% Specify the path to the data in DATA_PATH, and optionally specify names
|
|
% of signals to load.
|
|
raw_data = load(data_path, varargin{:});
|
|
fn = fieldnames(raw_data);
|
|
base_ts = datetime(0, 1, 0);
|
|
for i=1:numel(fn)
|
|
var = raw_data.(fn{i});
|
|
timestamps = days(var(:,1)) + base_ts;
|
|
tt{i} = array2timetable( ...
|
|
var(:,2), ...
|
|
"RowTimes",timestamps, ...
|
|
"VariableNames",{fn{i}} ...
|
|
);
|
|
end
|
|
data = synchronize(tt{:},"union","nearest");
|
|
% union -> union of the row times
|
|
% method -> fill gaps in output with nearest neighbor in the input timetable
|
|
end
|
|
|