フィルターのクリア

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

23 ビュー (過去 30 日間)
Joel
Joel 2023 年 6 月 7 日
コメント済み: Joel 2023 年 6 月 7 日
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.
Joel
Joel 2023 年 6 月 7 日
I figured it out... I dont make it a timetable till after I split it up into seperate tables.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTables についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by