Create a subtable with specific values in a column

12 views (last 30 days)
Hi!
I have a table with some demographic variables (age, gender, etc) and includes a column with participants ID. I need to create 2 subtables from this main table selecting only certain participants ID (as they were randomized there is no way to find a specific order to substract them). Each subtable should have only certain ID's (split into 2 groups basically). The rest of the variables/columns remain the same, I just need to find the specific rows (where ID is indicated).
I have tried using the function find, but I cannot use it with more than 3 input arguments.
The column ID would like something like this:
Subtable = find(Maintable.ID, 1245 1097 1893 1235 1514 1023 1071 1026 1009 1061 1033 1059 1551 1042 3008)
Any help would be much appreciated!
Thank you

Accepted Answer

madhan ravi
madhan ravi on 4 Sep 2019
ix = ismember(Maintable.ID, [1245 1097 1893 1235 1514 1023 1071 1026 1009 1061 1033 1059 1551 1042 3008]);
Subtable = Maintable(ix,:)

More Answers (0)

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!