I've got a list of ages in a table, sorted, and grouped by 'names'. Something like this:
perName=findgroups(data.names);b = splitapply(@(x1){sort(x1)}, data.age, perName);
How do I select the youngest 10 ages (smallest) for every name group (or largest for that matter)? Do I need to build a custom function then reference that function in the splitapply command?
Normally, I can sort the column and just trim out (or isolate) the top several using something like this (for example):
data(1:15,:) = [];
However, I've spent a long time without any luck to trim/isolate based on grouping. It was easy to get the min value using @min funciton, but I'm not sure how to get 'multiple' min or max values for each group
Also, once I've managed to find the top ten, how do I also isolate the corresponding rows in the table for different columns?
Any help is much appreciated!
(edit: I've attached the matlab table for reference. Note this is just made up 'dummy' data for practice. Once I figure it out I have to apply to a much larger dataset.)
Best Answer