How do I split a timetable into smaller timetables based on the data in a column in the timetable?

18 次查看(过去 30 天)
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})

回答(1 个)

Samay Sagar
Samay Sagar 2023-6-7
You can use table2timetable function to convert table to timetable. You can refer the docs here.
  2 个评论
Joel
Joel 2023-6-7
Thanks, I understand that but for some reason when I use the code above the output no longer contains the date time column so I cannot convert it to a timetable.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by