Split Table data based on Day Names

1 回表示 (過去 30 日間)
Ganesh Naik
Ganesh Naik 2021 年 4 月 16 日
コメント済み: Star Strider 2021 年 4 月 17 日
Hi all, I would like to split the table data based on Day Names (sample data attached). In detail, for my data I would like to split the table data for Monday, Tuesday etc (seven days) separately. Many thanks in advance

採用された回答

Star Strider
Star Strider 2021 年 4 月 16 日
Try this:
C1 = readcell('Sample.csv');
[G,ID] = findgroups(C1(:,6));
% Idx = [4 2 6 7 5 1 3]; % Manual Ordering
DayCell = splitapply(@(x){x}, C1, G);
DayStruct = cell2struct(DayCell,ID)
producing:
DayStruct =
struct with fields:
Friday: {41×8 cell}
Monday: {32×8 cell}
Saturday: {41×8 cell}
Sunday: {40×8 cell}
Thursday: {32×8 cell}
Tuesday: {33×8 cell}
Wednesday: {31×8 cell}
.
  2 件のコメント
Ganesh Naik
Ganesh Naik 2021 年 4 月 17 日
Hi Star Strider thank you very much for the answer. It is working for me. I am going to accept this answer.
Star Strider
Star Strider 2021 年 4 月 17 日
As always, my pleasure!
Thank you!

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2021 年 4 月 16 日
Do you want to have seven individual variables or do you want to operate on the set of rows in your table data where each row in the set has the same day name?
If the latter look at findgroups, splitapply, groupsummary, grouptransform, and the other functions listed in the "See Also" sections of the documentation pages for those functions. The stack or unstack functions may also be of interest. Alternately turn your table array into a timetable array and see if retime does what you want.
  1 件のコメント
Ganesh Naik
Ganesh Naik 2021 年 4 月 17 日
Hi Steve, thanks for your answer. I will go through with all the commands in detail.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by