How can I index for a specific value in a table?
8 ビュー (過去 30 日間)
古いコメントを表示
Hello,
For a statistical analysis I made a csv file. Imported it with use of the import tool. The colums I have are subject_nr, cue, set_size, order, deg_0 and correct_0. The statistical analysis needs to be preformed for each participant separate.
So I'm looking for a way to index from my table all the information from only 1 participant. I can index the whole row with subject_nr but thats not what I need.
0 件のコメント
回答 (1 件)
Steven Lord
2018 年 3 月 19 日
Logical indexing.
load patients
T = table(LastName, Gender, Age)
allMalePatients = T(ismember(T.Gender, 'Male'), :)
If you made Gender a categorical array then it becomes even easier.
GenderCat = categorical(Gender);
T2 = table(LastName, GenderCat, Age);
allMalePatients2 = T2(T2.GenderCat == 'Male', :)
Check that the two tables list the same patients (for purposes of this example, the patients each have a unique combination of last name and age.)
isequal(allMalePatients(:, {'LastName', 'Age'}), allMalePatients2(:, {'LastName', 'Age'}))
2 件のコメント
Peter Perkins
2018 年 3 月 23 日
What is it that you expect pp(i) to be? If you want to split the table into subtables, create pp as a 1x16 cell array and assign as pp{i} = ... .
But it's likely that you don't need to split your data like that. There are a number of ways to work on grouped data across all groups, in one table. See, for example, varfun and findgroups/splitapply.
参考
カテゴリ
Help Center および File Exchange で Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!