필터 지우기
필터 지우기

split table into smaller

조회 수: 5 (최근 30일)
Lotte Piek
Lotte Piek 2023년 2월 13일
댓글: Lotte Piek 2023년 2월 15일
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?

채택된 답변

Walter Roberson
Walter Roberson 2023년 2월 13일
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
Walter Roberson
Walter Roberson 2023년 2월 13일
Naming them all differently would involve dynamic generation of variable names, which is not recommended.
Lotte Piek
Lotte Piek 2023년 2월 15일
thanks!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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