split table into smaller

6 visualizaciones (últimos 30 días)
Lotte Piek
Lotte Piek el 13 de Feb. de 2023
Comentada: Lotte Piek el 15 de Feb. de 2023
Hi everyone,
I have a "big" table that has a data an time column. I want to split this big table into smaller one based upon indexes and name them all differently. Can anyone help?

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Feb. de 2023
At_a_time = 72; %for example
G = 1 + floor((0:height(YourTable)-1) / At_a_time).';
vars = YourTable.Properties.VariableNames;
parts = splitapply(@(varargin) table(varargin{:}, 'VariableNames', vars), YourTable, G);
parts will now be a cell array of tables, each height At_a_time.
There are more efficient ways using explicit loops.
  2 comentarios
Walter Roberson
Walter Roberson el 13 de Feb. de 2023
Naming them all differently would involve dynamic generation of variable names, which is not recommended.
Lotte Piek
Lotte Piek el 15 de Feb. de 2023
thanks!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

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