findgroup function is used to split the data based on the group and return groups numbers
splitapply function is used to apply the required function of the group and return the result
As an example from patients data first I am dividing the group based on Gender,Smoker,Age and at the end I was calculating the mean weight for each group
load patients.mat
GT=table(Gender,Smoker,Age);
[G,results] = findgroups(GT);
meanweight=splitapply(@mean,Weight,G);
results.meanWeight=meanweight;
results
You can use similar like above example!