Borrar filtros
Borrar filtros

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

23 visualizaciones (últimos 30 días)
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})

Respuestas (1)

Samay Sagar
Samay Sagar el 7 de Jun. de 2023
You can use table2timetable function to convert table to timetable. You can refer the docs here.
  2 comentarios
Joel
Joel el 7 de Jun. de 2023
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.
Joel
Joel el 7 de Jun. de 2023
I figured it out... I dont make it a timetable till after I split it up into seperate tables.

Iniciar sesión para comentar.

Categorías

Más información sobre Tables en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by