MATLAB: Separate table data in to sub tables

separate datasub-tabletable

Hi everyone
I have a table of data the size of 10000×3. There are 300 different names used in the rows. I would like to seperte the variables that have the same name and make a tabel for each variable.
for example if the table below is my original table :
name Variable1 variable2 variable3
A variable1_A1 variable2_A2 variable3_A3
B variable1_B1 variable2_B2 variable3_B3
K variable1_K1 variable2_K2 variable3_K3
L variable1_L1 variable2_L2 variable3_L3
A variable1_A4 variable2_A5 variable3_A6
A variable1_A7 variable2_A8 variable3_A9
L variable1_L4 variable2_L5 variable3_L6
I need to devide it to 4 differnt tables (one for each name):
name Variable1 variable2 variable3
A variable1_A1 variable2_A2 variable3_A3
A variable1_A4 variable2_A5 variable3_A6
A variable1_A7 variable2_A8 variable3_A9
name Variable1 variable2 variable3
L variable1_L1 variable2_L2 variable3_L3
L variable1_L4 variable2_L5 variable3_L6
Thank you in advance for your help!

Best Answer

G = findgroups(YourTable.name);
output = splitapply(@(varargin) {table(varargin{:}, 'VariableNames', YourTable.Properties.VariableNames)}, YourTable, G);
This should give a cell array of tables.
Related Question