How do I split a MATLAB table into seperate tables by date?
Mostrar comentarios más antiguos
I have a table with a datatime and temperature column that I want to split into seperate tables based on date. For example, I want to split the below table into 3 sperate tables because there are 3 different days in the table.
Date Temperature
2022-05-21 12
2021-05-21 19
2022-05-21 24
2022-06-01 21
2022-06-01 22
2022-06-04 25
How do I do this?
Respuesta aceptada
Más respuestas (1)
t = table( ...
{'2022-05-21';'2021-05-21';'2022-05-21';'2022-06-01';'2022-06-01';'2022-06-04'}, ...
[12;19;24;21;22;25], ...
'VariableNames',{'Date' 'Temperature'})
G = findgroups(t.Date);
c = splitapply(@(varargin) {table(varargin{:}, 'VariableNames', t.Properties.VariableNames)}, t, G);
c
1 comentario
Bhavishey Thapar
el 25 de Jul. de 2022
Categorías
Más información sobre Time Series Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!