How do I split a timetable into smaller timetables based on the data in a column in the timetable?
25 views (last 30 days)
Show older comments
I am splitting up a timetable that contains a datetime column and then a bunch of collumbs of hex code. I want to devide it up in groups based on the data in the fist collumb of hex. The code below works well but I want the outputs to be timetables and they are just tables.
Here is a sample of three rows from the timetable RAW that I am using:
'151-17:28:25.047688' "54E1" "5000" "0000" <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing>
'151-17:28:26.274193' "CC26" "C800" "2F47" "D682" "0000" "0004" "0000" "0020" <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing>
'151-17:28:53.149654' "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000" "0000"
% columnb number 1 is used
G = findgroups(RAW{:, 1});
% Split table based on 1553 status word (column 2)
T_split = splitapply( @(varargin) varargin, RAW , G);
% Allocate empty cell array fo size equal to number of rows in T_Split
subTables = cell(size(T_split, 1));
% Create sub tables
for i = 1:size(T_split, 1)
subTables{i} = table(T_split{i, :}, 'VariableNames', ...
RAW.Properties.VariableNames);
end
R = (subTables{1})
S = (subTables{2})
T = (subTables{3})
V = (subTables{4})
w = (subTables{5})
X = (subTables{6})
Y = (subTables{7})
Z = (subTables{8})
0 Comments
Answers (1)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!