%% Group by Largest Values
% Create a table containing two variables that represent a day number and temperature.

daynum = [1 1 1 1 2 2 2 2]';
temp = [67 65 71 55 61 79 58 78]';
T = table(daynum,temp)

% Group by day number, and return the largest two temperatures for each day.

G = groupfilter(T,'daynum',@(x) ismember(x,maxk(x,2)))

% Copyright 2019 The MathWorks, Inc.