How to split tables and extract all data based on a column value?
27 ビュー (過去 30 日間)
古いコメントを表示
Christoper Angelo Malayan
2020 年 11 月 18 日
コメント済み: Christoper Angelo Malayan
2020 年 11 月 18 日
Hi all. I'm new to MATLAB and coding in general. I'm practicing on this data set (r_T.mat).
I want to create separate tables based on values on column 'G'. These tables need to include all data (from column 'custNo' up to column 'p').
So the output should be 3 separate tables with all data still intact.
I can't seem to separate them will all data still intact. When I apply
r_T.G(r_T.G == 1)
it just outputs
ans =
1
1
1
1
1
and it does NOT extract ALL data from column 'custNo' up to column 'p' in a separate table.
To provide more context, my end goal is to run a while loop to get the sum of column 'd' up until <= a variable 'C' for each group in column 'G'.
Any help or tips is greatly appreciated. Thank you.
0 件のコメント
採用された回答
Cris LaPierre
2020 年 11 月 18 日
You are close. Don't forget to include both row and column indices, and make the outer variable the data you want to extract. In this case, that is probably the table name only.
load r_T.mat
r_T(r_T.G == 1,:)
sumTbl = groupsummary(r_T,'G','sum','d')
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!